Browse Source

add perl support to multishell, scriptwrap improvements including checkfile scan of scriptwrap templates/output files

master
Julian Noble 10 months ago
parent
commit
b3882878ec
  1. 20
      src/doc/punk/_module_fileline-0.1.0.tm.man
  2. 37
      src/doc/punk/_module_flib-0.1.0.tm.man
  3. 41
      src/embedded/man/files/punk/_module_fileline-0.1.0.tm.n
  4. 318
      src/embedded/man/files/punk/_module_flib-0.1.0.tm.n
  5. 3
      src/embedded/man/index.n
  6. 3
      src/embedded/man/toc.n
  7. 1
      src/embedded/md/.doc/tocdoc
  8. 2
      src/embedded/md/.idx
  9. 2
      src/embedded/md/.toc
  10. 2
      src/embedded/md/.xrf
  11. 117
      src/embedded/md/doc/files/punk/_module_fileline-0.1.0.tm.md
  12. 87
      src/embedded/md/doc/files/punk/_module_flib-0.1.0.tm.md
  13. 2
      src/embedded/md/doc/toc.md
  14. 2
      src/embedded/md/index.md
  15. 2
      src/embedded/md/toc.md
  16. 1
      src/embedded/www/.doc/tocdoc
  17. 2
      src/embedded/www/.idx
  18. 2
      src/embedded/www/.toc
  19. 2
      src/embedded/www/.xrf
  20. 94
      src/embedded/www/doc/files/punk/_module_fileline-0.1.0.tm.html
  21. 187
      src/embedded/www/doc/files/punk/_module_flib-0.1.0.tm.html
  22. 4
      src/embedded/www/doc/toc.html
  23. 2
      src/embedded/www/index.html
  24. 4
      src/embedded/www/toc.html
  25. 202
      src/modules/punk/fileline-999999.0a1.0.tm
  26. 55
      src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm
  27. 211
      src/modules/punk/mix/templates/utility/scriptappwrappers/punk-multishell.cmd
  28. 2
      src/scriptapps/fetchruntime.ps1
  29. 6
      src/scriptapps/punk87.tcl

20
src/doc/punk/_module_fileline-0.1.0.tm.man

@ -76,12 +76,25 @@ or
[para]A 'line' may be returned without a line-ending if the unerlying chunk had trailing data without a line-ending (or the chunk was loaded under a non-standard -policy setting)
[para]Whilst such data may not conform to definitions (e.g POSIX) of the terms 'textfile' and 'line' - it is useful here to represent it as a line with metadata le set to "none"
[para]To return just the data which might more commonly be needed for dealing with lines, use the [method linepayload] method - which returns the line data minus line-ending
[call class::textinfo [method linepayload_find_glob] [arg globsearch] [opt {option value...}]]
[para]Return a lineinfolist (see [method lineinfo] and [method lineinfolist]) of lines where payload matches the [arg globsearch] string
[para]To limit the returned results use the -limit n option - where -limit 0 means return all matches.
[para]For example: [method linepayload_find_glob] "*test*" -limit 1
[para]The result is always a list of lineinfo dictionaries even if one item is returned
[para] -limitfrom can be start|end
[para]The order of results is always the order as they occur in the data - even if -limitfrom end is specified.
[para]-limitfrom end means that only the last -limit items are returned
[para]Note that as glob accepts [lb]chars[rb]] to mean match any character in the set given by chars, searching for literal square brackets should be done by escaping the bracket with a backslash
[para]This is true even if only a single square bracket is being searched for. e.g {*[lb]file*} will not find the word file followed by a left square-bracket - even though the search didn't close the square brackets.
[para]In the above case - the literal search should be {*\[lb]file*}
[call class::textinfo [method linepayload] [arg lineindex]]
[para]Return the text of the line indicated by the zero-based lineindex
[para]The line-ending is not returned in the data - but is still stored against this lineindex
[para]Line Metadata such as the line-ending for a particular line and the byte/character range it occupies within the chunk can be retrieved with the [method linemeta] method
[para]To retrieve both the line text and metadata in a single call the [method lineinfo] method can be used
[para]To retrieve an entire line including line-ending use the [method line] method.
[call class::textinfo [method linepayloads] [arg startindex] [arg endindex]]
[para]Return a list of just the payloads in the specified linindex range, with no metadata.
[call class::textinfo [method linemeta] [arg lineindex]]
[para]Return a dict of the metadata for the line indicated by the zero-based lineindex
[para]Keys returned include
@ -146,7 +159,7 @@ or
[arg_def integer end]
[para] zero-based end index of range
[arg_def integer chunksize]
[para] Number of bytes/characters in chunk
[para] Number of bytes/characters in chunk - must be positive and > 0
[list_end]
[para]returns a dict with the keys is_span and boundaries
[para]is_span 0|1 indicates if the range specified spans a boundary of chunksize
@ -156,6 +169,11 @@ or
range_spans_chunk_boundaries 10 1750 512
is_span 1 boundaries {512 1024 1536}
[example_end]
[para]The -offset <int> option
[example_begin]
range_spans_chunk_boundaries 10 1750 512 -offset 2
is_span 1 boundaries {514 1026 1538}
[example_end]
[para] This function automatically uses lseq (if Tcl >= 8.7) when number of boundaries spanned is approximately greater than 75
[list_end] [comment {--- end definitions namespace punk::fileline::lib ---}]
[section Internal]

37
src/doc/punk/_module_flib-0.1.0.tm.man

@ -0,0 +1,37 @@
[comment {--- punk::docgen generated from inline doctools comments ---}]
[comment {--- punk::docgen DO NOT EDIT DOCS HERE UNLESS YOU REMOVE THESE COMMENT LINES ---}]
[comment {--- punk::docgen overwrites this file ---}]
[manpage_begin shellspy_module_punk::flib 0 0.1.0]
[copyright "2024"]
[titledesc {Module API}] [comment {-- Name section and table of contents description --}]
[moddesc {-}] [comment {-- Description at end of page heading --}]
[require punk::flib]
[keywords module]
[description]
[para] -
[section Overview]
[para] overview of punk::flib
[subsection Concepts]
[para] -
[subsection dependencies]
[para] packages used by punk::flib
[list_begin itemized]
[item] [package {Tcl 8.6}]
[list_end]
[section API]
[subsection {Namespace punk::flib::class}]
[para] class definitions
[list_begin enumerated]
[list_end] [comment {--- end class enumeration ---}]
[subsection {Namespace punk::flib}]
[para] Core API functions for punk::flib
[list_begin definitions]
[list_end] [comment {--- end definitions namespace punk::flib ---}]
[subsection {Namespace punk::flib::lib}]
[para] Secondary functions that are part of the API
[list_begin definitions]
[list_end] [comment {--- end definitions namespace punk::flib::lib ---}]
[section Internal]
[subsection {Namespace punk::flib::system}]
[para] Internal functions that are not part of the API
[manpage_end]

41
src/embedded/man/files/punk/_module_fileline-0.1.0.tm.n

@ -288,8 +288,12 @@ class::textinfo \fBlinecount\fR
.sp
class::textinfo \fBline\fR \fIlineindex\fR
.sp
class::textinfo \fBlinepayload_find_glob\fR \fIglobsearch\fR ?option value\&.\&.\&.?
.sp
class::textinfo \fBlinepayload\fR \fIlineindex\fR
.sp
class::textinfo \fBlinepayloads\fR \fIstartindex\fR \fIendindex\fR
.sp
class::textinfo \fBlinemeta\fR \fIlineindex\fR
.sp
class::textinfo \fBlineinfo\fR \fIlineindex\fR
@ -440,6 +444,28 @@ Whilst such data may not conform to definitions (e\&.g POSIX) of the terms 'text
.sp
To return just the data which might more commonly be needed for dealing with lines, use the \fBlinepayload\fR method - which returns the line data minus line-ending
.TP
class::textinfo \fBlinepayload_find_glob\fR \fIglobsearch\fR ?option value\&.\&.\&.?
.sp
Return a lineinfolist (see \fBlineinfo\fR and \fBlineinfolist\fR) of lines where payload matches the \fIglobsearch\fR string
.sp
To limit the returned results use the -limit n option - where -limit 0 means return all matches\&.
.sp
For example: \fBlinepayload_find_glob\fR "*test*" -limit 1
.sp
The result is always a list of lineinfo dictionaries even if one item is returned
.sp
-limitfrom can be start|end
.sp
The order of results is always the order as they occur in the data - even if -limitfrom end is specified\&.
.sp
-limitfrom end means that only the last -limit items are returned
.sp
Note that as glob accepts [chars]] to mean match any character in the set given by chars, searching for literal square brackets should be done by escaping the bracket with a backslash
.sp
This is true even if only a single square bracket is being searched for\&. e\&.g {*[file*} will not find the word file followed by a left square-bracket - even though the search didn't close the square brackets\&.
.sp
In the above case - the literal search should be {*\\[file*}
.TP
class::textinfo \fBlinepayload\fR \fIlineindex\fR
.sp
Return the text of the line indicated by the zero-based lineindex
@ -452,6 +478,10 @@ To retrieve both the line text and metadata in a single call the \fBlineinfo\fR
.sp
To retrieve an entire line including line-ending use the \fBline\fR method\&.
.TP
class::textinfo \fBlinepayloads\fR \fIstartindex\fR \fIendindex\fR
.sp
Return a list of just the payloads in the specified linindex range, with no metadata\&.
.TP
class::textinfo \fBlinemeta\fR \fIlineindex\fR
.sp
Return a dict of the metadata for the line indicated by the zero-based lineindex
@ -568,7 +598,7 @@ zero-based end index of range
.TP
integer \fIchunksize\fR
.sp
Number of bytes/characters in chunk
Number of bytes/characters in chunk - must be positive and > 0
.RE
.sp
returns a dict with the keys is_span and boundaries
@ -584,6 +614,15 @@ e\&.g
range_spans_chunk_boundaries 10 1750 512
is_span 1 boundaries {512 1024 1536}
.CE
.sp
The -offset <int> option
.CS
range_spans_chunk_boundaries 10 1750 512 -offset 2
is_span 1 boundaries {514 1026 1538}
.CE
.sp
This function automatically uses lseq (if Tcl >= 8\&.7) when number of boundaries spanned is approximately greater than 75

318
src/embedded/man/files/punk/_module_flib-0.1.0.tm.n

@ -0,0 +1,318 @@
'\"
'\" Generated from file '_module_flib-0\&.1\&.0\&.tm\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2024
'\"
.TH "shellspy_module_punk::flib" 0 0\&.1\&.0 doc "-"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\" Start paragraph describing an argument to a library procedure.
.\" type is type of argument (int, etc.), in/out is either "in", "out",
.\" or "in/out" to describe whether procedure reads or modifies arg,
.\" and indent is equivalent to second arg of .IP (shouldn't ever be
.\" needed; use .AS below instead)
.\"
.\" .AS ?type? ?name?
.\" Give maximum sizes of arguments for setting tab stops. Type and
.\" name are examples of largest possible arguments that will be passed
.\" to .AP later. If args are omitted, default tab stops are used.
.\"
.\" .BS
.\" Start box enclosure. From here until next .BE, everything will be
.\" enclosed in one large box.
.\"
.\" .BE
.\" End of box enclosure.
.\"
.\" .CS
.\" Begin code excerpt.
.\"
.\" .CE
.\" End code excerpt.
.\"
.\" .VS ?version? ?br?
.\" Begin vertical sidebar, for use in marking newly-changed parts
.\" of man pages. The first argument is ignored and used for recording
.\" the version when the .VS was added, so that the sidebars can be
.\" found and removed when they reach a certain age. If another argument
.\" is present, then a line break is forced before starting the sidebar.
.\"
.\" .VE
.\" End of vertical sidebar.
.\"
.\" .DS
.\" Begin an indented unfilled display.
.\"
.\" .DE
.\" End of indented unfilled display.
.\"
.\" .SO ?manpage?
.\" Start of list of standard options for a Tk widget. The manpage
.\" argument defines where to look up the standard options; if
.\" omitted, defaults to "options". The options follow on successive
.\" lines, in three columns separated by tabs.
.\"
.\" .SE
.\" End of list of standard options for a Tk widget.
.\"
.\" .OP cmdName dbName dbClass
.\" Start of description of a specific option. cmdName gives the
.\" option's name as specified in the class command, dbName gives
.\" the option's name in the option database, and dbClass gives
.\" the option's class in the option database.
.\"
.\" .UL arg1 arg2
.\" Print arg1 underlined, then print arg2 normally.
.\"
.\" .QW arg1 ?arg2?
.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation).
.\"
.\" .PQ arg1 ?arg2?
.\" Print an open parenthesis, arg1 in quotes, then arg2 normally
.\" (for trailing punctuation) and then a closing parenthesis.
.\"
.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
.\" # Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
.ta \\n()Au \\n()Bu
.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1 \\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
.\" # define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
.\" # BS - start boxed text
.\" # ^y = starting y location
.\" # ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
.\" # BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\" Draw four-sided box normally, but don't draw top of
.\" box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
.\" # VS - start vertical sidebar
.\" # ^Y = starting y location
.\" # ^v = 1 (for troff; for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
.\" # VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
.\" # Special macro to handle page bottom: finish off current
.\" # box/sidebar if in box/sidebar mode, then invoked standard
.\" # page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\" Draw three-sided box if this is the box's first page,
.\" draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
.\" # DS - begin display
.de DS
.RS
.nf
.sp
..
.\" # DE - end display
.de DE
.fi
.RE
.sp
..
.\" # SO - start of list of standard options
.de SO
'ie '\\$1'' .ds So \\fBoptions\\fR
'el .ds So \\fB\\$1\\fR
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 5.5c 11c
.ft B
..
.\" # SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\*(So manual entry for details on the standard options.
..
.\" # OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name: \\fB\\$1\\fR
Database Name: \\fB\\$2\\fR
Database Class: \\fB\\$3\\fR
.fi
.IP
..
.\" # CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
.\" # CE - end code excerpt
.de CE
.fi
.RE
..
.\" # UL - underline word
.de UL
\\$1\l'|0\(ul'\\$2
..
.\" # QW - apply quotation marks to word
.de QW
.ie '\\*(lq'"' ``\\$1''\\$2
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\$2
..
.\" # PQ - apply parens and quotation marks to word
.de PQ
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
.\"" fix emacs highlighting
.el (\\*(lq\\$1\\*(rq\\$2)\\$3
..
.\" # QR - quoted range
.de QR
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
..
.\" # MT - "empty" string
.de MT
.QW ""
..
.BS
.SH NAME
shellspy_module_punk::flib \- Module API
.SH SYNOPSIS
package require \fBpunk::flib \fR
.sp
.BE
.SH DESCRIPTION
.PP
-
.SH OVERVIEW
.PP
overview of punk::flib
.SS CONCEPTS
.PP
-
.SS DEPENDENCIES
.PP
packages used by punk::flib
.IP \(bu
\fBTcl 8\&.6\fR
.PP
.SH API
.SS "NAMESPACE PUNK::FLIB::CLASS"
.PP
class definitions
.PP
.SS "NAMESPACE PUNK::FLIB"
.PP
Core API functions for punk::flib
.PP
.SS "NAMESPACE PUNK::FLIB::LIB"
.PP
Secondary functions that are part of the API
.PP
.SH INTERNAL
.SS "NAMESPACE PUNK::FLIB::SYSTEM"
.PP
Internal functions that are not part of the API
.SH KEYWORDS
module
.SH COPYRIGHT
.nf
Copyright (c) 2024
.fi

3
src/embedded/man/index.n

@ -307,6 +307,9 @@ punkshell_module_punk::fileline
.TP
\fBfiles/punk/_module_path-0\&.1\&.0\&.tm\&.n\fR
punkshell_module_punk::path
.TP
\fBfiles/punk/_module_flib-0\&.1\&.0\&.tm\&.n\fR
shellspy_module_punk::flib
.RE
parse
.RS

3
src/embedded/man/toc.n

@ -293,3 +293,6 @@ doc
.TP
\fBpunkshell_module_punk::path\fR
\fIfiles/punk/_module_path-0\&.1\&.0\&.tm\&.n\fR: Filesystem path utilities
.TP
\fBshellspy_module_punk::flib\fR
\fIfiles/punk/_module_flib-0\&.1\&.0\&.tm\&.n\fR: Module API

1
src/embedded/md/.doc/tocdoc

@ -6,4 +6,5 @@
[item doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline {file line-handling utilities}]
[item doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md punkshell_module_punk::mix::commandset::project {pmix commandset - project}]
[item doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path {Filesystem path utilities}]
[item doc/files/punk/_module_flib-0.1.0.tm.md shellspy_module_punk::flib {Module API}]
[toc_end]

2
src/embedded/md/.idx

@ -1 +1 @@
{file {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline}} repl {{doc/files/project_intro.md punkshell__project_intro} {doc/files/project_changes.md punkshell__project_changes} {doc/files/main.md punkshell}} text {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline}} shell {{doc/files/project_intro.md punkshell__project_intro} {doc/files/project_changes.md punkshell__project_changes} {doc/files/main.md punkshell}} changelog {{doc/files/project_changes.md punkshell__project_changes}} capability {{doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap}} parse {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline}} filesystem {{doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path}} path {{doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path}} module {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} {doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} {doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path}} punk {{doc/files/project_intro.md punkshell__project_intro} {doc/files/project_changes.md punkshell__project_changes} {doc/files/main.md punkshell}} plugin {{doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap}}} {{shell doc/files/project_changes.md punkshell__project_changes} . {changelog doc/files/project_changes.md punkshell__project_changes} . {shell doc/files/main.md punkshell} . {text doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {repl doc/files/project_intro.md punkshell__project_intro} . {module doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} . {plugin doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} . {filesystem doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} . {path doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} . {module doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} . {punk doc/files/project_changes.md punkshell__project_changes} . {shell doc/files/project_intro.md punkshell__project_intro} . {parse doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {punk doc/files/main.md punkshell} . {module doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {repl doc/files/project_changes.md punkshell__project_changes} . {punk doc/files/project_intro.md punkshell__project_intro} . {file doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {repl doc/files/main.md punkshell} . {capability doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} .} 12 {file file repl repl text text shell shell changelog changelog capability capability parse parse filesystem filesystem path path module module punk punk plugin plugin}
{file {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline}} repl {{doc/files/project_intro.md punkshell__project_intro} {doc/files/project_changes.md punkshell__project_changes} {doc/files/main.md punkshell}} text {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline}} shell {{doc/files/project_intro.md punkshell__project_intro} {doc/files/project_changes.md punkshell__project_changes} {doc/files/main.md punkshell}} changelog {{doc/files/project_changes.md punkshell__project_changes}} capability {{doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap}} parse {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline}} filesystem {{doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path}} path {{doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path}} module {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} {doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} {doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} {doc/files/punk/_module_flib-0.1.0.tm.md shellspy_module_punk::flib}} punk {{doc/files/project_intro.md punkshell__project_intro} {doc/files/project_changes.md punkshell__project_changes} {doc/files/main.md punkshell}} plugin {{doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap}}} {{shell doc/files/project_changes.md punkshell__project_changes} . {changelog doc/files/project_changes.md punkshell__project_changes} . {shell doc/files/main.md punkshell} . {text doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {repl doc/files/project_intro.md punkshell__project_intro} . {module doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} . {plugin doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} . {filesystem doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} . {path doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} . {module doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path} . {punk doc/files/project_changes.md punkshell__project_changes} . {shell doc/files/project_intro.md punkshell__project_intro} . {parse doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {punk doc/files/main.md punkshell} . {module doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {module doc/files/punk/_module_flib-0.1.0.tm.md shellspy_module_punk::flib} . {repl doc/files/project_changes.md punkshell__project_changes} . {punk doc/files/project_intro.md punkshell__project_intro} . {file doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline} . {repl doc/files/main.md punkshell} . {capability doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap} .} 12 {file file repl repl text text shell shell changelog changelog capability capability parse parse filesystem filesystem path path module module punk punk plugin plugin}

2
src/embedded/md/.toc

@ -1 +1 @@
doc {doc/toc {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline {file line-handling utilities}} {doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap {capability provider and handler plugin system}} {doc/files/project_intro.md punkshell__project_intro {Introduction to punkshell}} {doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path {Filesystem path utilities}} {doc/files/project_changes.md punkshell__project_changes {punkshell Changes}} {doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md punkshell_module_punk::mix::commandset::project {pmix commandset - project}} {doc/files/main.md punkshell {punkshell - Core}}}}
doc {doc/toc {{doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::fileline {file line-handling utilities}} {doc/files/punk/_module_cap-0.1.0.tm.md punkshell_module_punk::cap {capability provider and handler plugin system}} {doc/files/project_intro.md punkshell__project_intro {Introduction to punkshell}} {doc/files/punk/_module_path-0.1.0.tm.md punkshell_module_punk::path {Filesystem path utilities}} {doc/files/punk/_module_flib-0.1.0.tm.md shellspy_module_punk::flib {Module API}} {doc/files/project_changes.md punkshell__project_changes {punkshell Changes}} {doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md punkshell_module_punk::mix::commandset::project {pmix commandset - project}} {doc/files/main.md punkshell {punkshell - Core}}}}

2
src/embedded/md/.xrf

@ -1 +1 @@
kw,capability {index.md capability} punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.md sa,punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md {punkshell Changes} doc/files/project_changes.md {Introduction to punkshell} doc/files/project_intro.md sa,punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md sa,punkshell(n) doc/files/main.md filesystem {index.md filesystem} sa,punkshell doc/files/main.md kw,shell {index.md shell} sa,punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.md sa,punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.md kw,parse {index.md parse} sa,punkshell__project_changes(n) doc/files/project_changes.md kw,path {index.md path} kw,module {index.md module} punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.md punkshell(n) doc/files/main.md kw,plugin {index.md plugin} punkshell doc/files/main.md kw,file {index.md file} punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.md changelog {index.md changelog} punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.md punkshell__project_changes(n) doc/files/project_changes.md sa,punkshell__project_changes doc/files/project_changes.md path {index.md path} file {index.md file} sa,punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.md punkshell__project_changes doc/files/project_changes.md kw,filesystem {index.md filesystem} sa,punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md shell {index.md shell} punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.md kw,repl {index.md repl} capability {index.md capability} kw,text {index.md text} parse {index.md parse} sa,punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md {punkshell - Core} doc/files/main.md {pmix commandset - project} doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md {capability provider and handler plugin system} doc/files/punk/_module_cap-0.1.0.tm.md repl {index.md repl} punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.md kw,punk {index.md punk} sa,punkshell__project_intro(n) doc/files/project_intro.md text {index.md text} sa,punkshell__project_intro doc/files/project_intro.md {Filesystem path utilities} doc/files/punk/_module_path-0.1.0.tm.md sa,punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.md punkshell__project_intro(n) doc/files/project_intro.md {file line-handling utilities} doc/files/punk/_module_fileline-0.1.0.tm.md punkshell__project_intro doc/files/project_intro.md kw,changelog {index.md changelog} module {index.md module} punk {index.md punk} plugin {index.md plugin}
kw,capability {index.md capability} punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.md sa,punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md {punkshell Changes} doc/files/project_changes.md {Introduction to punkshell} doc/files/project_intro.md sa,punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md sa,punkshell(n) doc/files/main.md filesystem {index.md filesystem} sa,punkshell doc/files/main.md kw,shell {index.md shell} sa,punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.md sa,punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.md kw,parse {index.md parse} sa,punkshell__project_changes(n) doc/files/project_changes.md kw,path {index.md path} kw,module {index.md module} punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.md punkshell(n) doc/files/main.md kw,plugin {index.md plugin} punkshell doc/files/main.md kw,file {index.md file} punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.md changelog {index.md changelog} punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.md punkshell__project_changes(n) doc/files/project_changes.md sa,punkshell__project_changes doc/files/project_changes.md path {index.md path} sa,shellspy_module_punk::flib(0) doc/files/punk/_module_flib-0.1.0.tm.md file {index.md file} sa,punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.md punkshell__project_changes doc/files/project_changes.md kw,filesystem {index.md filesystem} sa,punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md shellspy_module_punk::flib(0) doc/files/punk/_module_flib-0.1.0.tm.md {Module API} doc/files/punk/_module_flib-0.1.0.tm.md shell {index.md shell} punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.md kw,repl {index.md repl} capability {index.md capability} kw,text {index.md text} parse {index.md parse} sa,punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.md punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md {punkshell - Core} doc/files/main.md {pmix commandset - project} doc/files/punk/mix/commandset/_module_project-0.1.0.tm.md {capability provider and handler plugin system} doc/files/punk/_module_cap-0.1.0.tm.md repl {index.md repl} punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.md kw,punk {index.md punk} sa,punkshell__project_intro(n) doc/files/project_intro.md text {index.md text} sa,punkshell__project_intro doc/files/project_intro.md {Filesystem path utilities} doc/files/punk/_module_path-0.1.0.tm.md sa,shellspy_module_punk::flib doc/files/punk/_module_flib-0.1.0.tm.md sa,punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.md punkshell__project_intro(n) doc/files/project_intro.md {file line-handling utilities} doc/files/punk/_module_fileline-0.1.0.tm.md punkshell__project_intro doc/files/project_intro.md kw,changelog {index.md changelog} module {index.md module} punk {index.md punk} shellspy_module_punk::flib doc/files/punk/_module_flib-0.1.0.tm.md plugin {index.md plugin}

117
src/embedded/md/doc/files/punk/_module_fileline-0.1.0.tm.md

@ -58,24 +58,26 @@ package require punk::fileline
[class::textinfo __chunk\_boundary\_display__](#4)
[class::textinfo __linecount__](#5)
[class::textinfo __line__ *lineindex*](#6)
[class::textinfo __linepayload__ *lineindex*](#7)
[class::textinfo __linemeta__ *lineindex*](#8)
[class::textinfo __lineinfo__ *lineindex*](#9)
[class::textinfo __lineinfolist__ *startidx* *endidx*](#10)
[class::textinfo __linerange\_to\_chunkrange__ *startidx* *endidx*](#11)
[class::textinfo __linerange\_to\_chunk__ *startidx* *endidx*](#12)
[class::textinfo __lines__ *startidx* *endidx*](#13)
[class::textinfo __linepayloads__ *startidx* *endidx*](#14)
[class::textinfo __chunkrange\_to\_linerange__ *chunkstart* *chunkend*](#15)
[class::textinfo __chunkrange\_to\_lineinfolist__ *chunkstart* *chunkend* ?option value\.\.\.?](#16)
[class::textinfo __numeric\_linerange__ *startidx* *endidx*](#17)
[class::textinfo __numeric\_chunkrange__ *startidx* *endidx*](#18)
[class::textinfo __normalize\_indices__ *startidx* *endidx* *max*](#19)
[class::textinfo __regenerate\_lines__](#20)
[__lib::range\_spans\_chunk\_boundaries__ *start* *end* *chunksize*](#21)
[__ansi::a__](#22)
[__ansi::a\+__](#23)
[__ansi::stripansi__](#24)
[class::textinfo __linepayload\_find\_glob__ *globsearch* ?option value\.\.\.?](#7)
[class::textinfo __linepayload__ *lineindex*](#8)
[class::textinfo __linepayloads__ *startindex* *endindex*](#9)
[class::textinfo __linemeta__ *lineindex*](#10)
[class::textinfo __lineinfo__ *lineindex*](#11)
[class::textinfo __lineinfolist__ *startidx* *endidx*](#12)
[class::textinfo __linerange\_to\_chunkrange__ *startidx* *endidx*](#13)
[class::textinfo __linerange\_to\_chunk__ *startidx* *endidx*](#14)
[class::textinfo __lines__ *startidx* *endidx*](#15)
[class::textinfo __linepayloads__ *startidx* *endidx*](#16)
[class::textinfo __chunkrange\_to\_linerange__ *chunkstart* *chunkend*](#17)
[class::textinfo __chunkrange\_to\_lineinfolist__ *chunkstart* *chunkend* ?option value\.\.\.?](#18)
[class::textinfo __numeric\_linerange__ *startidx* *endidx*](#19)
[class::textinfo __numeric\_chunkrange__ *startidx* *endidx*](#20)
[class::textinfo __normalize\_indices__ *startidx* *endidx* *max*](#21)
[class::textinfo __regenerate\_lines__](#22)
[__lib::range\_spans\_chunk\_boundaries__ *start* *end* *chunksize*](#23)
[__ansi::a__](#24)
[__ansi::a\+__](#25)
[__ansi::stripansi__](#26)
# <a name='description'></a>DESCRIPTION
@ -210,7 +212,38 @@ class definitions
with lines, use the __linepayload__ method \- which returns the line
data minus line\-ending
- <a name='7'></a>class::textinfo __linepayload__ *lineindex*
- <a name='7'></a>class::textinfo __linepayload\_find\_glob__ *globsearch* ?option value\.\.\.?
Return a lineinfolist \(see __lineinfo__ and __lineinfolist__\)
of lines where payload matches the *globsearch* string
To limit the returned results use the \-limit n option \- where \-limit 0
means return all matches\.
For example: __linepayload\_find\_glob__ "\*test\*" \-limit 1
The result is always a list of lineinfo dictionaries even if one item
is returned
\-limitfrom can be start&#124;end
The order of results is always the order as they occur in the data \-
even if \-limitfrom end is specified\.
\-limitfrom end means that only the last \-limit items are returned
Note that as glob accepts \[chars\]\] to mean match any character in the
set given by chars, searching for literal square brackets should be
done by escaping the bracket with a backslash
This is true even if only a single square bracket is being searched
for\. e\.g \{\*\[file\*\} will not find the word file followed by a left
square\-bracket \- even though the search didn't close the square
brackets\.
In the above case \- the literal search should be \{\*\\\[file\*\}
- <a name='8'></a>class::textinfo __linepayload__ *lineindex*
Return the text of the line indicated by the zero\-based lineindex
@ -227,7 +260,12 @@ class definitions
To retrieve an entire line including line\-ending use the __line__
method\.
- <a name='8'></a>class::textinfo __linemeta__ *lineindex*
- <a name='9'></a>class::textinfo __linepayloads__ *startindex* *endindex*
Return a list of just the payloads in the specified linindex range,
with no metadata\.
- <a name='10'></a>class::textinfo __linemeta__ *lineindex*
Return a dict of the metadata for the line indicated by the zero\-based
lineindex
@ -260,7 +298,7 @@ class definitions
This end\-point corresponds to the last character of the line\-ending
if any \- not necessarily the last character of the line's payload
- <a name='9'></a>class::textinfo __lineinfo__ *lineindex*
- <a name='11'></a>class::textinfo __lineinfo__ *lineindex*
Return a dict of the metadata and text for the line indicated by the
zero\-based lineindex
@ -271,22 +309,22 @@ class definitions
The 'payload' value is the same as is returned from the
__linepayload__ method\.
- <a name='10'></a>class::textinfo __lineinfolist__ *startidx* *endidx*
- <a name='12'></a>class::textinfo __lineinfolist__ *startidx* *endidx*
Returns list of lineinfo dicts for each line in line index range
startidx to endidx
- <a name='11'></a>class::textinfo __linerange\_to\_chunkrange__ *startidx* *endidx*
- <a name='13'></a>class::textinfo __linerange\_to\_chunkrange__ *startidx* *endidx*
- <a name='12'></a>class::textinfo __linerange\_to\_chunk__ *startidx* *endidx*
- <a name='14'></a>class::textinfo __linerange\_to\_chunk__ *startidx* *endidx*
- <a name='13'></a>class::textinfo __lines__ *startidx* *endidx*
- <a name='15'></a>class::textinfo __lines__ *startidx* *endidx*
- <a name='14'></a>class::textinfo __linepayloads__ *startidx* *endidx*
- <a name='16'></a>class::textinfo __linepayloads__ *startidx* *endidx*
- <a name='15'></a>class::textinfo __chunkrange\_to\_linerange__ *chunkstart* *chunkend*
- <a name='17'></a>class::textinfo __chunkrange\_to\_linerange__ *chunkstart* *chunkend*
- <a name='16'></a>class::textinfo __chunkrange\_to\_lineinfolist__ *chunkstart* *chunkend* ?option value\.\.\.?
- <a name='18'></a>class::textinfo __chunkrange\_to\_lineinfolist__ *chunkstart* *chunkend* ?option value\.\.\.?
Return a list of dicts each with structure like the result of the
__lineinfo__ method \- but possibly with extra keys for truncation
@ -303,7 +341,7 @@ class definitions
method \- and will not be reflected in __lineinfo__ queries to the
main chunk\.
- <a name='17'></a>class::textinfo __numeric\_linerange__ *startidx* *endidx*
- <a name='19'></a>class::textinfo __numeric\_linerange__ *startidx* *endidx*
A helper to return any Tcl\-style end end\-x values given to startidx or
endidx; converted to their specific values based on the current state
@ -312,13 +350,13 @@ class definitions
This is used internally by API functions such as __line__ to enable
it to accept more expressive indices
- <a name='18'></a>class::textinfo __numeric\_chunkrange__ *startidx* *endidx*
- <a name='20'></a>class::textinfo __numeric\_chunkrange__ *startidx* *endidx*
A helper to return any Tcl\-style end end\-x entries supplied to startidx
or endidx; converted to their specific values based on the current
state of the underlying chunk data
- <a name='19'></a>class::textinfo __normalize\_indices__ *startidx* *endidx* *max*
- <a name='21'></a>class::textinfo __normalize\_indices__ *startidx* *endidx* *max*
A utility to convert some of the of Tcl\-style list\-index expressions
such as end, end\-1 etc to valid indices in the range 0 to the supplied
@ -331,7 +369,7 @@ class definitions
Unlike Tcl's index expressions \- we raise an error if the calculated
index is out of bounds 0 to max
- <a name='20'></a>class::textinfo __regenerate\_lines__
- <a name='22'></a>class::textinfo __regenerate\_lines__
generate a list of lines from the current state of the stored raw data
chunk and keep a map of line\-endings indexed by lineindex
@ -349,7 +387,7 @@ Core API functions for punk::fileline
## <a name='subsection7'></a>Namespace punk::fileline::lib
- <a name='21'></a>__lib::range\_spans\_chunk\_boundaries__ *start* *end* *chunksize*
- <a name='23'></a>__lib::range\_spans\_chunk\_boundaries__ *start* *end* *chunksize*
Takes start and end offset, generally representing bytes or character
indices, and computes a list of boundaries at multiples of the chunksize
@ -365,7 +403,7 @@ Core API functions for punk::fileline
* integer *chunksize*
Number of bytes/characters in chunk
Number of bytes/characters in chunk \- must be positive and > 0
returns a dict with the keys is\_span and boundaries
@ -379,6 +417,11 @@ Core API functions for punk::fileline
range_spans_chunk_boundaries 10 1750 512
is_span 1 boundaries {512 1024 1536}
The \-offset <int> option
range_spans_chunk_boundaries 10 1750 512 -offset 2
is_span 1 boundaries {514 1026 1538}
This function automatically uses lseq \(if Tcl >= 8\.7\) when number of
boundaries spanned is approximately greater than 75
@ -395,11 +438,11 @@ unavailable
See __punk::ansi__ for documentation
- <a name='22'></a>__ansi::a__
- <a name='24'></a>__ansi::a__
- <a name='23'></a>__ansi::a\+__
- <a name='25'></a>__ansi::a\+__
- <a name='24'></a>__ansi::stripansi__
- <a name='26'></a>__ansi::stripansi__
# <a name='keywords'></a>KEYWORDS

87
src/embedded/md/doc/files/punk/_module_flib-0.1.0.tm.md

@ -0,0 +1,87 @@
[//000000001]: # (shellspy\_module\_punk::flib \- \-)
[//000000002]: # (Generated from file '\_module\_flib\-0\.1\.0\.tm\.man' by tcllib/doctools with format 'markdown')
[//000000003]: # (Copyright &copy; 2024)
[//000000004]: # (shellspy\_module\_punk::flib\(0\) 0\.1\.0 doc "\-")
<hr> [ <a href="../../../toc.md">Main Table Of Contents</a> &#124; <a
href="../../toc.md">Table Of Contents</a> &#124; <a
href="../../../index.md">Keyword Index</a> ] <hr>
# NAME
shellspy\_module\_punk::flib \- Module API
# <a name='toc'></a>Table Of Contents
- [Table Of Contents](#toc)
- [Synopsis](#synopsis)
- [Description](#section1)
- [Overview](#section2)
- [Concepts](#subsection1)
- [dependencies](#subsection2)
- [API](#section3)
- [Namespace punk::flib::class](#subsection3)
- [Namespace punk::flib](#subsection4)
- [Namespace punk::flib::lib](#subsection5)
- [Internal](#section4)
- [Namespace punk::flib::system](#subsection6)
- [Keywords](#keywords)
- [Copyright](#copyright)
# <a name='synopsis'></a>SYNOPSIS
package require punk::flib
# <a name='description'></a>DESCRIPTION
\-
# <a name='section2'></a>Overview
overview of punk::flib
## <a name='subsection1'></a>Concepts
\-
## <a name='subsection2'></a>dependencies
packages used by punk::flib
- __Tcl 8\.6__
# <a name='section3'></a>API
## <a name='subsection3'></a>Namespace punk::flib::class
class definitions
## <a name='subsection4'></a>Namespace punk::flib
## <a name='subsection5'></a>Namespace punk::flib::lib
# <a name='section4'></a>Internal
## <a name='subsection6'></a>Namespace punk::flib::system
# <a name='keywords'></a>KEYWORDS
[module](\.\./\.\./\.\./index\.md\#module)
# <a name='copyright'></a>COPYRIGHT
Copyright &copy; 2024

2
src/embedded/md/doc/toc.md

@ -16,3 +16,5 @@
- [punkshell\_module\_punk::mix::commandset::project](doc/files/punk/mix/commandset/\_module\_project\-0\.1\.0\.tm\.md) pmix commandset \- project
- [punkshell\_module\_punk::path](doc/files/punk/\_module\_path\-0\.1\.0\.tm\.md) Filesystem path utilities
- [shellspy\_module\_punk::flib](doc/files/punk/\_module\_flib\-0\.1\.0\.tm\.md) Module API

2
src/embedded/md/index.md

@ -29,7 +29,7 @@
|||
|---|---|
|<a name='module'></a>module|[punkshell\_module\_punk::cap](doc/files/punk/\_module\_cap\-0\.1\.0\.tm\.md) &#183; [punkshell\_module\_punk::fileline](doc/files/punk/\_module\_fileline\-0\.1\.0\.tm\.md) &#183; [punkshell\_module\_punk::path](doc/files/punk/\_module\_path\-0\.1\.0\.tm\.md)|
|<a name='module'></a>module|[punkshell\_module\_punk::cap](doc/files/punk/\_module\_cap\-0\.1\.0\.tm\.md) &#183; [punkshell\_module\_punk::fileline](doc/files/punk/\_module\_fileline\-0\.1\.0\.tm\.md) &#183; [punkshell\_module\_punk::path](doc/files/punk/\_module\_path\-0\.1\.0\.tm\.md) &#183; [shellspy\_module\_punk::flib](doc/files/punk/\_module\_flib\-0\.1\.0\.tm\.md)|
#### <a name='cP'></a>Keywords: P

2
src/embedded/md/toc.md

@ -16,3 +16,5 @@
- [punkshell\_module\_punk::mix::commandset::project](doc/files/punk/mix/commandset/\_module\_project\-0\.1\.0\.tm\.md) pmix commandset \- project
- [punkshell\_module\_punk::path](doc/files/punk/\_module\_path\-0\.1\.0\.tm\.md) Filesystem path utilities
- [shellspy\_module\_punk::flib](doc/files/punk/\_module\_flib\-0\.1\.0\.tm\.md) Module API

1
src/embedded/www/.doc/tocdoc

@ -6,4 +6,5 @@
[item doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline {file line-handling utilities}]
[item doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html punkshell_module_punk::mix::commandset::project {pmix commandset - project}]
[item doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path {Filesystem path utilities}]
[item doc/files/punk/_module_flib-0.1.0.tm.html shellspy_module_punk::flib {Module API}]
[toc_end]

2
src/embedded/www/.idx

@ -1 +1 @@
{file {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline}} repl {{doc/files/project_intro.html punkshell__project_intro} {doc/files/project_changes.html punkshell__project_changes} {doc/files/main.html punkshell}} text {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline}} shell {{doc/files/project_intro.html punkshell__project_intro} {doc/files/project_changes.html punkshell__project_changes} {doc/files/main.html punkshell}} changelog {{doc/files/project_changes.html punkshell__project_changes}} capability {{doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap}} parse {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline}} filesystem {{doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path}} path {{doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path}} module {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} {doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} {doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path}} punk {{doc/files/project_intro.html punkshell__project_intro} {doc/files/project_changes.html punkshell__project_changes} {doc/files/main.html punkshell}} plugin {{doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap}}} {{repl doc/files/main.html punkshell} . {file doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {punk doc/files/project_intro.html punkshell__project_intro} . {capability doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} . {shell doc/files/project_changes.html punkshell__project_changes} . {changelog doc/files/project_changes.html punkshell__project_changes} . {shell doc/files/main.html punkshell} . {text doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {repl doc/files/project_intro.html punkshell__project_intro} . {module doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} . {path doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} . {plugin doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} . {filesystem doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} . {module doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} . {shell doc/files/project_intro.html punkshell__project_intro} . {punk doc/files/project_changes.html punkshell__project_changes} . {parse doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {punk doc/files/main.html punkshell} . {module doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {repl doc/files/project_changes.html punkshell__project_changes} .} 12 {file file repl repl text text shell shell changelog changelog capability capability parse parse filesystem filesystem path path module module punk punk plugin plugin}
{file {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline}} repl {{doc/files/project_intro.html punkshell__project_intro} {doc/files/project_changes.html punkshell__project_changes} {doc/files/main.html punkshell}} text {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline}} shell {{doc/files/project_intro.html punkshell__project_intro} {doc/files/project_changes.html punkshell__project_changes} {doc/files/main.html punkshell}} changelog {{doc/files/project_changes.html punkshell__project_changes}} capability {{doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap}} parse {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline}} filesystem {{doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path}} path {{doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path}} module {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} {doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} {doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} {doc/files/punk/_module_flib-0.1.0.tm.html shellspy_module_punk::flib}} punk {{doc/files/project_intro.html punkshell__project_intro} {doc/files/project_changes.html punkshell__project_changes} {doc/files/main.html punkshell}} plugin {{doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap}}} {{repl doc/files/main.html punkshell} . {file doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {punk doc/files/project_intro.html punkshell__project_intro} . {capability doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} . {shell doc/files/project_changes.html punkshell__project_changes} . {changelog doc/files/project_changes.html punkshell__project_changes} . {shell doc/files/main.html punkshell} . {text doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {repl doc/files/project_intro.html punkshell__project_intro} . {module doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} . {path doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} . {plugin doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap} . {filesystem doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} . {module doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path} . {shell doc/files/project_intro.html punkshell__project_intro} . {punk doc/files/project_changes.html punkshell__project_changes} . {parse doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {punk doc/files/main.html punkshell} . {module doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline} . {module doc/files/punk/_module_flib-0.1.0.tm.html shellspy_module_punk::flib} . {repl doc/files/project_changes.html punkshell__project_changes} .} 12 {file file repl repl text text shell shell changelog changelog capability capability parse parse filesystem filesystem path path module module punk punk plugin plugin}

2
src/embedded/www/.toc

@ -1 +1 @@
doc {doc/toc {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline {file line-handling utilities}} {doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap {capability provider and handler plugin system}} {doc/files/project_intro.html punkshell__project_intro {Introduction to punkshell}} {doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path {Filesystem path utilities}} {doc/files/project_changes.html punkshell__project_changes {punkshell Changes}} {doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html punkshell_module_punk::mix::commandset::project {pmix commandset - project}} {doc/files/main.html punkshell {punkshell - Core}}}}
doc {doc/toc {{doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::fileline {file line-handling utilities}} {doc/files/punk/_module_cap-0.1.0.tm.html punkshell_module_punk::cap {capability provider and handler plugin system}} {doc/files/project_intro.html punkshell__project_intro {Introduction to punkshell}} {doc/files/punk/_module_path-0.1.0.tm.html punkshell_module_punk::path {Filesystem path utilities}} {doc/files/punk/_module_flib-0.1.0.tm.html shellspy_module_punk::flib {Module API}} {doc/files/project_changes.html punkshell__project_changes {punkshell Changes}} {doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html punkshell_module_punk::mix::commandset::project {pmix commandset - project}} {doc/files/main.html punkshell {punkshell - Core}}}}

2
src/embedded/www/.xrf

@ -1 +1 @@
kw,capability {index.html capability} punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.html sa,punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html {punkshell Changes} doc/files/project_changes.html {Introduction to punkshell} doc/files/project_intro.html sa,punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html sa,punkshell(n) doc/files/main.html filesystem {index.html filesystem} sa,punkshell doc/files/main.html kw,shell {index.html shell} sa,punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.html sa,punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.html kw,parse {index.html parse} sa,punkshell__project_changes(n) doc/files/project_changes.html kw,path {index.html path} kw,module {index.html module} punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.html punkshell(n) doc/files/main.html kw,plugin {index.html plugin} punkshell doc/files/main.html kw,file {index.html file} punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.html changelog {index.html changelog} punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.html punkshell__project_changes(n) doc/files/project_changes.html sa,punkshell__project_changes doc/files/project_changes.html path {index.html path} file {index.html file} sa,punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.html punkshell__project_changes doc/files/project_changes.html kw,filesystem {index.html filesystem} sa,punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html shell {index.html shell} punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.html kw,repl {index.html repl} capability {index.html capability} kw,text {index.html text} parse {index.html parse} sa,punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html {punkshell - Core} doc/files/main.html {pmix commandset - project} doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html {capability provider and handler plugin system} doc/files/punk/_module_cap-0.1.0.tm.html repl {index.html repl} punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.html kw,punk {index.html punk} sa,punkshell__project_intro(n) doc/files/project_intro.html text {index.html text} sa,punkshell__project_intro doc/files/project_intro.html {Filesystem path utilities} doc/files/punk/_module_path-0.1.0.tm.html sa,punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.html punkshell__project_intro(n) doc/files/project_intro.html {file line-handling utilities} doc/files/punk/_module_fileline-0.1.0.tm.html punkshell__project_intro doc/files/project_intro.html kw,changelog {index.html changelog} module {index.html module} punk {index.html punk} plugin {index.html plugin}
kw,capability {index.html capability} punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.html sa,punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html {punkshell Changes} doc/files/project_changes.html {Introduction to punkshell} doc/files/project_intro.html sa,punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::mix::commandset::project(0) doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html sa,punkshell(n) doc/files/main.html filesystem {index.html filesystem} sa,punkshell doc/files/main.html kw,shell {index.html shell} sa,punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.html sa,punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.html kw,parse {index.html parse} sa,punkshell__project_changes(n) doc/files/project_changes.html kw,path {index.html path} kw,module {index.html module} punkshell_module_punk::fileline(0) doc/files/punk/_module_fileline-0.1.0.tm.html punkshell(n) doc/files/main.html kw,plugin {index.html plugin} punkshell doc/files/main.html kw,file {index.html file} punkshell_module_punk::cap doc/files/punk/_module_cap-0.1.0.tm.html changelog {index.html changelog} punkshell_module_punk::cap(0) doc/files/punk/_module_cap-0.1.0.tm.html punkshell__project_changes(n) doc/files/project_changes.html sa,punkshell__project_changes doc/files/project_changes.html path {index.html path} sa,shellspy_module_punk::flib(0) doc/files/punk/_module_flib-0.1.0.tm.html file {index.html file} sa,punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.html punkshell__project_changes doc/files/project_changes.html kw,filesystem {index.html filesystem} sa,punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html shellspy_module_punk::flib(0) doc/files/punk/_module_flib-0.1.0.tm.html {Module API} doc/files/punk/_module_flib-0.1.0.tm.html shell {index.html shell} punkshell_module_punk::path doc/files/punk/_module_path-0.1.0.tm.html kw,repl {index.html repl} capability {index.html capability} kw,text {index.html text} parse {index.html parse} sa,punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.html punkshell_module_punk::mix::commandset::project doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html {punkshell - Core} doc/files/main.html {pmix commandset - project} doc/files/punk/mix/commandset/_module_project-0.1.0.tm.html {capability provider and handler plugin system} doc/files/punk/_module_cap-0.1.0.tm.html repl {index.html repl} punkshell_module_punk::fileline doc/files/punk/_module_fileline-0.1.0.tm.html kw,punk {index.html punk} sa,punkshell__project_intro(n) doc/files/project_intro.html text {index.html text} sa,punkshell__project_intro doc/files/project_intro.html {Filesystem path utilities} doc/files/punk/_module_path-0.1.0.tm.html sa,shellspy_module_punk::flib doc/files/punk/_module_flib-0.1.0.tm.html sa,punkshell_module_punk::path(0) doc/files/punk/_module_path-0.1.0.tm.html punkshell__project_intro(n) doc/files/project_intro.html {file line-handling utilities} doc/files/punk/_module_fileline-0.1.0.tm.html punkshell__project_intro doc/files/project_intro.html kw,changelog {index.html changelog} module {index.html module} punk {index.html punk} shellspy_module_punk::flib doc/files/punk/_module_flib-0.1.0.tm.html plugin {index.html plugin}

94
src/embedded/www/doc/files/punk/_module_fileline-0.1.0.tm.html

@ -149,24 +149,26 @@
<li><a href="#4">class::textinfo <b class="method">chunk_boundary_display</b></a></li>
<li><a href="#5">class::textinfo <b class="method">linecount</b></a></li>
<li><a href="#6">class::textinfo <b class="method">line</b> <i class="arg">lineindex</i></a></li>
<li><a href="#7">class::textinfo <b class="method">linepayload</b> <i class="arg">lineindex</i></a></li>
<li><a href="#8">class::textinfo <b class="method">linemeta</b> <i class="arg">lineindex</i></a></li>
<li><a href="#9">class::textinfo <b class="method">lineinfo</b> <i class="arg">lineindex</i></a></li>
<li><a href="#10">class::textinfo <b class="method">lineinfolist</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#11">class::textinfo <b class="method">linerange_to_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#12">class::textinfo <b class="method">linerange_to_chunk</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#13">class::textinfo <b class="method">lines</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#14">class::textinfo <b class="method">linepayloads</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#15">class::textinfo <b class="method">chunkrange_to_linerange</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i></a></li>
<li><a href="#16">class::textinfo <b class="method">chunkrange_to_lineinfolist</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i> <span class="opt">?option value...?</span></a></li>
<li><a href="#17">class::textinfo <b class="method">numeric_linerange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#18">class::textinfo <b class="method">numeric_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#19">class::textinfo <b class="method">normalize_indices</b> <i class="arg">startidx</i> <i class="arg">endidx</i> <i class="arg">max</i></a></li>
<li><a href="#20">class::textinfo <b class="method">regenerate_lines</b></a></li>
<li><a href="#21"><b class="function">lib::range_spans_chunk_boundaries</b> <i class="arg">start</i> <i class="arg">end</i> <i class="arg">chunksize</i></a></li>
<li><a href="#22"><b class="function">ansi::a</b></a></li>
<li><a href="#23"><b class="function">ansi::a+</b></a></li>
<li><a href="#24"><b class="function">ansi::stripansi</b></a></li>
<li><a href="#7">class::textinfo <b class="method">linepayload_find_glob</b> <i class="arg">globsearch</i> <span class="opt">?option value...?</span></a></li>
<li><a href="#8">class::textinfo <b class="method">linepayload</b> <i class="arg">lineindex</i></a></li>
<li><a href="#9">class::textinfo <b class="method">linepayloads</b> <i class="arg">startindex</i> <i class="arg">endindex</i></a></li>
<li><a href="#10">class::textinfo <b class="method">linemeta</b> <i class="arg">lineindex</i></a></li>
<li><a href="#11">class::textinfo <b class="method">lineinfo</b> <i class="arg">lineindex</i></a></li>
<li><a href="#12">class::textinfo <b class="method">lineinfolist</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#13">class::textinfo <b class="method">linerange_to_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#14">class::textinfo <b class="method">linerange_to_chunk</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#15">class::textinfo <b class="method">lines</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#16">class::textinfo <b class="method">linepayloads</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#17">class::textinfo <b class="method">chunkrange_to_linerange</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i></a></li>
<li><a href="#18">class::textinfo <b class="method">chunkrange_to_lineinfolist</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i> <span class="opt">?option value...?</span></a></li>
<li><a href="#19">class::textinfo <b class="method">numeric_linerange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#20">class::textinfo <b class="method">numeric_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></li>
<li><a href="#21">class::textinfo <b class="method">normalize_indices</b> <i class="arg">startidx</i> <i class="arg">endidx</i> <i class="arg">max</i></a></li>
<li><a href="#22">class::textinfo <b class="method">regenerate_lines</b></a></li>
<li><a href="#23"><b class="function">lib::range_spans_chunk_boundaries</b> <i class="arg">start</i> <i class="arg">end</i> <i class="arg">chunksize</i></a></li>
<li><a href="#24"><b class="function">ansi::a</b></a></li>
<li><a href="#25"><b class="function">ansi::a+</b></a></li>
<li><a href="#26"><b class="function">ansi::stripansi</b></a></li>
</ul>
</div>
</div>
@ -245,13 +247,26 @@ or
<p>A 'line' may be returned without a line-ending if the unerlying chunk had trailing data without a line-ending (or the chunk was loaded under a non-standard -policy setting)</p>
<p>Whilst such data may not conform to definitions (e.g POSIX) of the terms 'textfile' and 'line' - it is useful here to represent it as a line with metadata le set to &quot;none&quot;</p>
<p>To return just the data which might more commonly be needed for dealing with lines, use the <b class="method">linepayload</b> method - which returns the line data minus line-ending</p></dd>
<dt><a name="7">class::textinfo <b class="method">linepayload</b> <i class="arg">lineindex</i></a></dt>
<dt><a name="7">class::textinfo <b class="method">linepayload_find_glob</b> <i class="arg">globsearch</i> <span class="opt">?option value...?</span></a></dt>
<dd><p>Return a lineinfolist (see <b class="method">lineinfo</b> and <b class="method">lineinfolist</b>) of lines where payload matches the <i class="arg">globsearch</i> string</p>
<p>To limit the returned results use the -limit n option - where -limit 0 means return all matches.</p>
<p>For example: <b class="method">linepayload_find_glob</b> &quot;*test*&quot; -limit 1</p>
<p>The result is always a list of lineinfo dictionaries even if one item is returned</p>
<p>-limitfrom can be start|end</p>
<p>The order of results is always the order as they occur in the data - even if -limitfrom end is specified.</p>
<p>-limitfrom end means that only the last -limit items are returned</p>
<p>Note that as glob accepts [chars]] to mean match any character in the set given by chars, searching for literal square brackets should be done by escaping the bracket with a backslash</p>
<p>This is true even if only a single square bracket is being searched for. e.g {*[file*} will not find the word file followed by a left square-bracket - even though the search didn't close the square brackets.</p>
<p>In the above case - the literal search should be {*\[file*}</p></dd>
<dt><a name="8">class::textinfo <b class="method">linepayload</b> <i class="arg">lineindex</i></a></dt>
<dd><p>Return the text of the line indicated by the zero-based lineindex</p>
<p>The line-ending is not returned in the data - but is still stored against this lineindex</p>
<p>Line Metadata such as the line-ending for a particular line and the byte/character range it occupies within the chunk can be retrieved with the <b class="method">linemeta</b> method</p>
<p>To retrieve both the line text and metadata in a single call the <b class="method">lineinfo</b> method can be used</p>
<p>To retrieve an entire line including line-ending use the <b class="method">line</b> method.</p></dd>
<dt><a name="8">class::textinfo <b class="method">linemeta</b> <i class="arg">lineindex</i></a></dt>
<dt><a name="9">class::textinfo <b class="method">linepayloads</b> <i class="arg">startindex</i> <i class="arg">endindex</i></a></dt>
<dd><p>Return a list of just the payloads in the specified linindex range, with no metadata.</p></dd>
<dt><a name="10">class::textinfo <b class="method">linemeta</b> <i class="arg">lineindex</i></a></dt>
<dd><p>Return a dict of the metadata for the line indicated by the zero-based lineindex</p>
<p>Keys returned include</p>
<ul class="doctools_itemized">
@ -267,38 +282,38 @@ or
<p>The zero-based index into the associated raw file data indicating at which byte/character index this line ends</p>
<p>This end-point corresponds to the last character of the line-ending if any - not necessarily the last character of the line's payload</p></li>
</ul></dd>
<dt><a name="9">class::textinfo <b class="method">lineinfo</b> <i class="arg">lineindex</i></a></dt>
<dt><a name="11">class::textinfo <b class="method">lineinfo</b> <i class="arg">lineindex</i></a></dt>
<dd><p>Return a dict of the metadata and text for the line indicated by the zero-based lineindex</p>
<p>This returns the same info as the <b class="method">linemeta</b> with an added key of 'payload' which is the text of the line without line-ending.</p>
<p>The 'payload' value is the same as is returned from the <b class="method">linepayload</b> method.</p></dd>
<dt><a name="10">class::textinfo <b class="method">lineinfolist</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="12">class::textinfo <b class="method">lineinfolist</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd><p>Returns list of lineinfo dicts for each line in line index range startidx to endidx</p></dd>
<dt><a name="11">class::textinfo <b class="method">linerange_to_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="13">class::textinfo <b class="method">linerange_to_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd></dd>
<dt><a name="12">class::textinfo <b class="method">linerange_to_chunk</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="14">class::textinfo <b class="method">linerange_to_chunk</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd></dd>
<dt><a name="13">class::textinfo <b class="method">lines</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="15">class::textinfo <b class="method">lines</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd></dd>
<dt><a name="14">class::textinfo <b class="method">linepayloads</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="16">class::textinfo <b class="method">linepayloads</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd></dd>
<dt><a name="15">class::textinfo <b class="method">chunkrange_to_linerange</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i></a></dt>
<dt><a name="17">class::textinfo <b class="method">chunkrange_to_linerange</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i></a></dt>
<dd></dd>
<dt><a name="16">class::textinfo <b class="method">chunkrange_to_lineinfolist</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i> <span class="opt">?option value...?</span></a></dt>
<dt><a name="18">class::textinfo <b class="method">chunkrange_to_lineinfolist</b> <i class="arg">chunkstart</i> <i class="arg">chunkend</i> <span class="opt">?option value...?</span></a></dt>
<dd><p>Return a list of dicts each with structure like the result of the <b class="method">lineinfo</b> method - but possibly with extra keys for truncation information if -show_truncated 1 is supplied</p>
<p>The truncation key in a lineinfo dict may be returned for first and/or last line in the resulting list.</p>
<p>truncation shows the shortened (missing bytes on left and/or right side) part of the entire line (potentially including line-ending or even partial line-ending)</p>
<p>Note that this truncation info is only in the return value of this method - and will not be reflected in <b class="method">lineinfo</b> queries to the main chunk.</p></dd>
<dt><a name="17">class::textinfo <b class="method">numeric_linerange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="19">class::textinfo <b class="method">numeric_linerange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd><p>A helper to return any Tcl-style end end-x values given to startidx or endidx; converted to their specific values based on the current state of the underlying line data</p>
<p>This is used internally by API functions such as <b class="method">line</b> to enable it to accept more expressive indices</p></dd>
<dt><a name="18">class::textinfo <b class="method">numeric_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dt><a name="20">class::textinfo <b class="method">numeric_chunkrange</b> <i class="arg">startidx</i> <i class="arg">endidx</i></a></dt>
<dd><p>A helper to return any Tcl-style end end-x entries supplied to startidx or endidx; converted to their specific values based on the current state of the underlying chunk data</p></dd>
<dt><a name="19">class::textinfo <b class="method">normalize_indices</b> <i class="arg">startidx</i> <i class="arg">endidx</i> <i class="arg">max</i></a></dt>
<dt><a name="21">class::textinfo <b class="method">normalize_indices</b> <i class="arg">startidx</i> <i class="arg">endidx</i> <i class="arg">max</i></a></dt>
<dd><p>A utility to convert some of the of Tcl-style list-index expressions such as end, end-1 etc to valid indices in the range 0 to the supplied max</p>
<p>Basic addition and subtraction expressions such as 4-1 5+2 are accepted</p>
<p>startidx higher than endidx is allowed</p>
<p>Unlike Tcl's index expressions - we raise an error if the calculated index is out of bounds 0 to max</p></dd>
<dt><a name="20">class::textinfo <b class="method">regenerate_lines</b></a></dt>
<dt><a name="22">class::textinfo <b class="method">regenerate_lines</b></a></dt>
<dd><p>generate a list of lines from the current state of the stored raw data chunk and keep a map of line-endings indexed by lineindex</p>
<p>This is called automatically by the Constructor during object creation</p>
<p>It is exposed in the API experimentally - as chunk and line manipulation functions are considered.</p>
@ -315,7 +330,7 @@ or
<div id="subsection7" class="doctools_subsection"><h3><a name="subsection7">Namespace punk::fileline::lib</a></h3>
<p>Secondary functions that are part of the API</p>
<dl class="doctools_definitions">
<dt><a name="21"><b class="function">lib::range_spans_chunk_boundaries</b> <i class="arg">start</i> <i class="arg">end</i> <i class="arg">chunksize</i></a></dt>
<dt><a name="23"><b class="function">lib::range_spans_chunk_boundaries</b> <i class="arg">start</i> <i class="arg">end</i> <i class="arg">chunksize</i></a></dt>
<dd><p>Takes start and end offset, generally representing bytes or character indices, and computes a list of boundaries at multiples of the chunksize that are spanned by the start and end range.</p>
<dl class="doctools_arguments">
@ -324,7 +339,7 @@ or
<dt>integer <i class="arg">end</i></dt>
<dd><p>zero-based end index of range</p></dd>
<dt>integer <i class="arg">chunksize</i></dt>
<dd><p>Number of bytes/characters in chunk</p></dd>
<dd><p>Number of bytes/characters in chunk - must be positive and &gt; 0</p></dd>
</dl>
<p>returns a dict with the keys is_span and boundaries</p>
<p>is_span 0|1 indicates if the range specified spans a boundary of chunksize</p>
@ -334,6 +349,11 @@ or
range_spans_chunk_boundaries 10 1750 512
is_span 1 boundaries {512 1024 1536}
</pre>
<p>The -offset &lt;int&gt; option</p>
<pre class="doctools_example">
range_spans_chunk_boundaries 10 1750 512 -offset 2
is_span 1 boundaries {514 1026 1538}
</pre>
<p>This function automatically uses lseq (if Tcl &gt;= 8.7) when number of boundaries spanned is approximately greater than 75</p></dd>
</dl>
</div>
@ -346,11 +366,11 @@ or
<p>These are ansi functions imported from punk::ansi - or no-ops if that package is unavailable</p>
<p>See <b class="package">punk::ansi</b> for documentation</p>
<dl class="doctools_definitions">
<dt><a name="22"><b class="function">ansi::a</b></a></dt>
<dt><a name="24"><b class="function">ansi::a</b></a></dt>
<dd></dd>
<dt><a name="23"><b class="function">ansi::a+</b></a></dt>
<dt><a name="25"><b class="function">ansi::a+</b></a></dt>
<dd></dd>
<dt><a name="24"><b class="function">ansi::stripansi</b></a></dt>
<dt><a name="26"><b class="function">ansi::stripansi</b></a></dt>
<dd></dd>
</dl>
</div>

187
src/embedded/www/doc/files/punk/_module_flib-0.1.0.tm.html

@ -0,0 +1,187 @@
<!DOCTYPE html><html><head>
<title>shellspy_module_punk::flib - -</title>
<style type="text/css"><!--
HTML {
background: #FFFFFF;
color: black;
}
BODY {
background: #FFFFFF;
color: black;
}
DIV.doctools {
margin-left: 10%;
margin-right: 10%;
}
DIV.doctools H1,DIV.doctools H2 {
margin-left: -5%;
}
H1, H2, H3, H4 {
margin-top: 1em;
font-family: sans-serif;
font-size: large;
color: #005A9C;
background: transparent;
text-align: left;
}
H1.doctools_title {
text-align: center;
}
UL,OL {
margin-right: 0em;
margin-top: 3pt;
margin-bottom: 3pt;
}
UL LI {
list-style: disc;
}
OL LI {
list-style: decimal;
}
DT {
padding-top: 1ex;
}
UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
font: normal 12pt/14pt sans-serif;
list-style: none;
}
LI.doctools_section, LI.doctools_subsection {
list-style: none;
margin-left: 0em;
text-indent: 0em;
padding: 0em;
}
PRE {
display: block;
font-family: monospace;
white-space: pre;
margin: 0%;
padding-top: 0.5ex;
padding-bottom: 0.5ex;
padding-left: 1ex;
padding-right: 1ex;
width: 100%;
}
PRE.doctools_example {
color: black;
background: #f5dcb3;
border: 1px solid black;
}
UL.doctools_requirements LI, UL.doctools_syntax LI {
list-style: none;
margin-left: 0em;
text-indent: 0em;
padding: 0em;
}
DIV.doctools_synopsis {
color: black;
background: #80ffff;
border: 1px solid black;
font-family: serif;
margin-top: 1em;
margin-bottom: 1em;
}
UL.doctools_syntax {
margin-top: 1em;
border-top: 1px solid black;
}
UL.doctools_requirements {
margin-bottom: 1em;
border-bottom: 1px solid black;
}
--></style>
</head>
<!-- Generated from file '_module_flib-0.1.0.tm.man' by tcllib/doctools with format 'html'
-->
<!-- Copyright &amp;copy; 2024
-->
<!-- shellspy_module_punk::flib.0
-->
<body><hr> [
<a href="../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../toc.html">Table Of Contents</a>
&#124; <a href="../../../index.html">Keyword Index</a>
] <hr>
<div class="doctools">
<h1 class="doctools_title">shellspy_module_punk::flib(0) 0.1.0 doc &quot;-&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>shellspy_module_punk::flib - Module API</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">Overview</a>
<ul>
<li class="doctools_subsection"><a href="#subsection1">Concepts</a></li>
<li class="doctools_subsection"><a href="#subsection2">dependencies</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#section3">API</a>
<ul>
<li class="doctools_subsection"><a href="#subsection3">Namespace punk::flib::class</a></li>
<li class="doctools_subsection"><a href="#subsection4">Namespace punk::flib</a></li>
<li class="doctools_subsection"><a href="#subsection5">Namespace punk::flib::lib</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#section4">Internal</a>
<ul>
<li class="doctools_subsection"><a href="#subsection6">Namespace punk::flib::system</a></li>
</ul>
</li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">punk::flib</b></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>-</p>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">Overview</a></h2>
<p>overview of punk::flib</p>
<div id="subsection1" class="doctools_subsection"><h3><a name="subsection1">Concepts</a></h3>
<p>-</p>
</div>
<div id="subsection2" class="doctools_subsection"><h3><a name="subsection2">dependencies</a></h3>
<p>packages used by punk::flib</p>
<ul class="doctools_itemized">
<li><p><b class="package">Tcl 8.6</b></p></li>
</ul>
</div>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">API</a></h2>
<div id="subsection3" class="doctools_subsection"><h3><a name="subsection3">Namespace punk::flib::class</a></h3>
<p>class definitions</p>
<ol class="doctools_enumerated">
</ol>
</div>
<div id="subsection4" class="doctools_subsection"><h3><a name="subsection4">Namespace punk::flib</a></h3>
<p>Core API functions for punk::flib</p>
<dl class="doctools_definitions">
</dl>
</div>
<div id="subsection5" class="doctools_subsection"><h3><a name="subsection5">Namespace punk::flib::lib</a></h3>
<p>Secondary functions that are part of the API</p>
<dl class="doctools_definitions">
</dl>
</div>
</div>
<div id="section4" class="doctools_section"><h2><a name="section4">Internal</a></h2>
<div id="subsection6" class="doctools_subsection"><h3><a name="subsection6">Namespace punk::flib::system</a></h3>
<p>Internal functions that are not part of the API</p>
</div>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../index.html#module">module</a></p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2024</p>
</div>
</div></body></html>

4
src/embedded/www/doc/toc.html

@ -40,5 +40,9 @@
<td class="#doctools_tocleft" ><a name='punkshell_module_punk_path'><a href="files/punk/_module_path-0.1.0.tm.html">punkshell_module_punk::path</a></td>
<td class="#doctools_tocright">Filesystem path utilities</td>
</tr>
<tr class="#doctools_tocodd" >
<td class="#doctools_tocleft" ><a name='shellspy_module_punk_flib'><a href="files/punk/_module_flib-0.1.0.tm.html">shellspy_module_punk::flib</a></td>
<td class="#doctools_tocright">Module API</td>
</tr>
</table>
</dd></dl><hr></body></html>

2
src/embedded/www/index.html

@ -48,7 +48,7 @@
<tr class="#doctools_idxeven" valign=top>
<td class="#doctools_idxleft" width="35%"><a name="module"> module </a></td>
<td class="#doctools_idxright" width="65%">
<a href="doc/files/punk/_module_cap-0.1.0.tm.html"> punkshell_module_punk::cap </a> &#183; <a href="doc/files/punk/_module_fileline-0.1.0.tm.html"> punkshell_module_punk::fileline </a> &#183; <a href="doc/files/punk/_module_path-0.1.0.tm.html"> punkshell_module_punk::path </a>
<a href="doc/files/punk/_module_cap-0.1.0.tm.html"> punkshell_module_punk::cap </a> &#183; <a href="doc/files/punk/_module_fileline-0.1.0.tm.html"> punkshell_module_punk::fileline </a> &#183; <a href="doc/files/punk/_module_path-0.1.0.tm.html"> punkshell_module_punk::path </a> &#183; <a href="doc/files/punk/_module_flib-0.1.0.tm.html"> shellspy_module_punk::flib </a>
</td></tr>
<tr class="#doctools_idxheader"><th colspan="2">
<a name="cP">Keywords: P</a>

4
src/embedded/www/toc.html

@ -40,5 +40,9 @@
<td class="#doctools_tocleft" ><a name='punkshell_module_punk_path'><a href="doc/files/punk/_module_path-0.1.0.tm.html">punkshell_module_punk::path</a></td>
<td class="#doctools_tocright">Filesystem path utilities</td>
</tr>
<tr class="#doctools_tocodd" >
<td class="#doctools_tocleft" ><a name='shellspy_module_punk_flib'><a href="doc/files/punk/_module_flib-0.1.0.tm.html">shellspy_module_punk::flib</a></td>
<td class="#doctools_tocright">Module API</td>
</tr>
</table>
</dd></dl><hr></body></html>

202
src/modules/punk/fileline-999999.0a1.0.tm

@ -129,11 +129,14 @@ namespace eval punk::fileline::class {
#[list_begin definitions]
# [para] [emph METHODS]
variable o_chunk
variable o_chunk ;#current state
variable o_chunkop_store
variable o_lineop_store
variable o_chunk_epoch
variable o_line_epoch
variable o_payloadlist
variable o_linemap
variable o_line_epoch
variable o_LF_C
variable o_CRLF_C
@ -158,22 +161,27 @@ namespace eval punk::fileline::class {
}
namespace path $nspath
}
set o_chunk $datachunk
set o_line_epoch [list]
set o_chunk_epoch [list "fromchunkchange-at-[clock micros]"]
set crlf_lf_placeholders [list \uFFFF \uFFFE] ;#defaults - if already exist in file - error out with message
set defaults [dict create\
-substitutionmap {}\
-crlf_lf_placeholders $crlf_lf_placeholders\
-userid "<pid-[pid]-tid-[thread::id]>"\
]
set known_opts [dict keys $defaults]
foreach {k v} $args {
if {$k ni $known_opts} {
error "textinfo::constructor error: unknown option '$k'. Known options: $known_opts"
error "[self] constructor error: unknown option '$k'. Known options: $known_opts"
}
}
set opts [dict merge $defaults $args]
# -- --- --- --- --- --- ---
set opt_substitutionmap [dict get $opts -substitutionmap] ;#review - can be done by caller - or a loadable -policy
set opt_crlf_lf_placeholders [dict get $opts -crlf_lf_placeholders]
set opt_substitutionmap [dict get $opts -substitutionmap] ;#review - can be done by caller - or a loadable -policy
set opt_crlf_lf_placeholders [dict get $opts -crlf_lf_placeholders]
set opt_userid [dict get $opts -userid]
# -- --- --- --- --- --- ---
if {[llength $opt_crlf_lf_placeholders] != 2 || [string length [lindex $opt_crlf_lf_placeholders 0]] !=1 || [string length [lindex $opt_crlf_lf_placeholders 1]] !=1} {
@ -201,8 +209,7 @@ namespace eval punk::fileline::class {
if {$o_LF_C eq $o_CRLF_C} {
puts stderr "WARNING: same substitution character used for both elements of -crlf_lf_placeholders - byte counting may be off if file contains mixed line-endings"
}
set o_chunk_epoch "initial"
set o_line_epoch ""
my regenerate_lines
}
@ -544,6 +551,103 @@ namespace eval punk::fileline::class {
set le_chars [dict get [dict create lf \n crlf \r\n none ""] $le]
return [lindex $o_payloadlist $lineindex]$le_chars
}
method chunk_find_glob {globsearch args} {
#todo - use linepayload_find_glob when -ignore_lineendings is 0 - but check truncations for 1st and last line
error "unimplemented"
}
method linepayload_find_glob {globsearch args} {
#*** !doctools
#[call class::textinfo [method linepayload_find_glob] [arg globsearch] [opt {option value...}]]
#[para]Return a lineinfolist (see [method lineinfo] and [method lineinfolist]) of lines where payload matches the [arg globsearch] string
#[para]To limit the returned results use the -limit n option - where -limit 0 means return all matches.
#[para]For example: [method linepayload_find_glob] "*test*" -limit 1
#[para]The result is always a list of lineinfo dictionaries even if one item is returned
#[para] -limitfrom can be start|end
#[para]The order of results is always the order as they occur in the data - even if -limitfrom end is specified.
#[para]-limitfrom end means that only the last -limit items are returned
#[para]Note that as glob accepts [lb]chars[rb]] to mean match any character in the set given by chars, searching for literal square brackets should be done by escaping the bracket with a backslash
#[para]This is true even if only a single square bracket is being searched for. e.g {*[lb]file*} will not find the word file followed by a left square-bracket - even though the search didn't close the square brackets.
#[para]In the above case - the literal search should be {*\[lb]file*}
set defaults [dict create\
-limit 0\
-strategy 1\
-start 0\
-end end\
-limitfrom start\
]
set known_opts [dict keys $defaults]
dict for {k v} $args {
if {$k ni $known_opts} {
error "linepayload_find_glob unknown option '$k'. Known options: $known_opts"
}
}
set opts [dict merge $defaults $args]
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
set opt_limit [dict get $opts -limit]
if {![string is integer -strict $opt_limit] || $opt_limit < 0} {
error "linepayload_find_glob -limit must be positive integer"
}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
set opt_strategy [dict get $opts -strategy]
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
set opt_start [dict get $opts -start]
set opt_start [expr {$opt_start}]
if {$opt_start != 0} {error "-start unimplemented"}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
set opt_end [dict get $opts -end]
set max_line_index [expr {[llength $o_payloadlist]-1}]
if {$opt_end eq "end"} {
set opt_end $max_line_index
}
#TODO
if {$opt_end < $max_line_index} {error "-end less than max_line_index unimplemented"}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
set opt_limitfrom [dict get $opts -limitfrom]
#-limitfrom start|end only
#TODO
if {$opt_limitfrom ne "start"} {error "-limitfrom unimplemented"}
# -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
set lineinfolist [list]
if {$opt_limit == 1} {
set idx [lsearch -glob [lrange $o_payloadlist $opt_start $opt_end] $globsearch]
if {$idx >=0} {
set i [expr {$opt_start + $idx}]
lappend lineinfolist [list lineindex $i [dict get $o_linemap $i] payload [lindex $o_payloadlist $i]]
}
} elseif {$opt_limit == 0} {
set indices [lsearch -all -glob [lrange $o_payloadlist $opt_start $opt_end] $globsearch]
foreach irel $indices {
set i [expr {$opt_start + $irel}]
lappend lineinfolist [list lineindex $i [dict get $o_linemap $i] payload [lindex $o_payloadlist $i]]
}
} else {
#todo - auto-strategy based on limit vs number of lines
if {$opt_strategy == 0} {
set posn 0
for {set r 0} {$r < $opt_limit} {incr r} {
set n [lsearch [lrange $o_payloadlist $posn+$opt_start end] $globsearch]
if {$n >=0} {
set irel [expr {$posn + $n}]
set i [expr {$irel + $opt_start}]
lappend lineinfolist [list lineindex $i {*}[dict get $o_linemap $i] payload [lindex $o_payloadlist $i]]
set posn [expr {$irel+1}]
}
}
} else {
set indices [lsearch -all -glob [lrange $o_payloadlist $opt_start $opt_end] $globsearch]
set limited [lrange $indices 0 $opt_limit-1]
foreach irel $limited {
set i [expr {$opt_start + $irel}]
lappend lineinfolist [list lineindex $i {*}[dict get $o_linemap $i] payload [lindex $o_payloadlist $i]]
}
}
}
return $lineinfolist
}
method linepayload {lineindex} {
#*** !doctools
#[call class::textinfo [method linepayload] [arg lineindex]]
@ -555,6 +659,12 @@ namespace eval punk::fileline::class {
lassign [my numeric_linerange $lineindex 0] lineindex
return [lindex $o_payloadlist $lineindex]
}
method linepayloads {startindex endindex} {
#*** !doctools
#[call class::textinfo [method linepayloads] [arg startindex] [arg endindex]]
#[para]Return a list of just the payloads in the specified linindex range, with no metadata.
return [lrange $o_payloadlist $startindex $endindex]
}
method linemeta {lineindex} {
#*** !doctools
#[call class::textinfo [method linemeta] [arg lineindex]]
@ -956,7 +1066,7 @@ namespace eval punk::fileline::class {
return [list $startidx $endidx]
}
method regenerate_lines {} {
method regenerate_lines {args} {
#*** !doctools
#[call class::textinfo [method regenerate_lines]]
#[para]generate a list of lines from the current state of the stored raw data chunk and keep a map of line-endings indexed by lineindex
@ -1021,7 +1131,7 @@ namespace eval punk::fileline::class {
set payloadlen [string length $lfpart]
if {$i == $imax} {
#no more lf segments - but we did find crlf in last (or perhaps only) lf line
#last element must be an empty crlf line or has no le
#last element in our split has no le
if {$payloadlen > 0} {
set le_size 0
set le none
@ -1032,14 +1142,8 @@ namespace eval punk::fileline::class {
}
} else {
#more lf segments to come
#last element must be an empty lf line or has no le
if {$payloadlen > 0} {
set le_size 0
set le none
} else {
set le_size 1
set le lf
}
}
lappend o_payloadlist $lfpart
@ -1059,7 +1163,16 @@ namespace eval punk::fileline::class {
}
method regenerate_chunk {} {
#o_payloadlist
#o_linemap
set oldsize [string length $o_chunk]
set newchunk ""
dict for {idx lineinfo} $o_linemap {
set
}
return [list newsize [string length $newchunk] oldsize $oldsize]
}
@ -1141,7 +1254,7 @@ namespace eval punk::fileline::lib {
# [arg_def integer end]
# [para] zero-based end index of range
# [arg_def integer chunksize]
# [para] Number of bytes/characters in chunk
# [para] Number of bytes/characters in chunk - must be positive and > 0
#[list_end]
#[para]returns a dict with the keys is_span and boundaries
#[para]is_span 0|1 indicates if the range specified spans a boundary of chunksize
@ -1151,19 +1264,34 @@ namespace eval punk::fileline::lib {
# range_spans_chunk_boundaries 10 1750 512
# is_span 1 boundaries {512 1024 1536}
#[example_end]
#[para]The -offset <int> option
#[example_begin]
# range_spans_chunk_boundaries 10 1750 512 -offset 2
# is_span 1 boundaries {514 1026 1538}
#[example_end]
#[para] This function automatically uses lseq (if Tcl >= 8.7) when number of boundaries spanned is approximately greater than 75
if {[catch {package require Tcl 8.7}]} {
#only one implementation available for older Tcl
tailcall punk::fileline::system::_range_spans_chunk_boundaries_tcl $start $end $chunksize {*}$args
}
if {(($end - $start) / $chunksize) < 75} {
if {$chunksize < 1} {
error "range_spans_chunk_boundaries chunksize must be >= 1"
}
if {(abs($end - $start) / $chunksize) < 75} {
tailcall punk::fileline::system::_range_spans_chunk_boundaries_tcl $start $end $chunksize {*}$args
} else {
tailcall punk::fileline::system::_range_spans_chunk_boundaries_lseq $start $end $chunksize {*}$args
}
}
proc range_boundaries {start end chunksizes args} {
lassign [punk::get_leading_opts_and_values {\
-offset 0\
} $args] _opts opts _vals remainingargs
}
#*** !doctools
#[list_end] [comment {--- end definitions namespace punk::fileline::lib ---}]
@ -1184,6 +1312,7 @@ namespace eval punk::fileline::system {
#for 8.7+ using lseq
#much faster when resultant boundary size is large (at least when offset 0)
proc _range_spans_chunk_boundaries_lseq {start end chunksize args} {
if {$chunksize < 1} {error "chunksize must be > 0"} ;#sanitycheck in case called directly
set defaults [dict create\
-offset 0\
]
@ -1206,16 +1335,32 @@ namespace eval punk::fileline::system {
}
}
set boundaries [lseq $start to $end $chunksize]
#offset can be negative
if {$opt_offset} {
set boundaries [lap v $boundaries[unset boundaries] {expr {$v + $opt_offset}}]
if {$opt_offset + [lindex $boundaries end] > $end || $opt_offset + [lindex $boundaries 0] < $start} {
set overflow 1
} else {
set overflow 0
}
set boundaries [lmap v $boundaries[unset boundaries] {expr {$v + $opt_offset}}]
if {$overflow} {
#we don't know how many overflowed..
set inrange [list]
foreach b $boundaries {
if {$b >= $start && $b <= $end} {
lappend inrange $b
}
}
set boundaries $inrange
}
}
return [list is_span [expr {[llength $boundaries]>0}] boundaries $boundaries]
}
#faster than lseq for small number of resultant boundaries (~< 75) (which is a common use case)
#gets very slow (comparitively) with large resultsets
proc _range_spans_chunk_boundaries_tcl {start end chunksize args} {
if {$chunksize < 1} {error "chunksize must be > 0"} ;#sanitycheck in case called directly
set defaults [dict create\
-offset 0\
]
@ -1236,9 +1381,24 @@ namespace eval punk::fileline::system {
set start [expr {$start + ($chunksize - $smod)}]
}
set boundaries [list]
for {set b $start} {$b <= $end} {incr b $chunksize} {
lappend boundaries [expr {$b + $opt_offset}]
#we only need to pre-check the result-range for negative offsets - as our main loop stops before end?
if {$opt_offset < 0} {
#set btrack [expr {$start + $opt_offset}] ;#start back one to make sure we catch the first boundary
set btrack $bstart
set boff [expr {$btrack + $opt_offset}] ;#must be growing even if start and offset are negative - as chunksize is at least 1
while {$boff < $start} {
incr btrack $chunksize
set boff [expr {$btrack + $opt_offset}]
}
set bstart $btrack
} else {
set bstart $start
}
for {set b $bstart} {[set boff [expr {$b + $opt_offset}]] <= $end} {incr b $chunksize} {
lappend boundaries $boff
}
return [list is_span [expr {[llength $boundaries]>0}] boundaries $boundaries offset $opt_offset]
}

55
src/modules/punk/mix/commandset/scriptwrap-999999.0a1.0.tm

@ -110,9 +110,9 @@ namespace eval punk::mix::commandset::scriptwrap {
#The windows batch file scanner appears to parse in 512 Byte chunks.
#If a label following a call/goto is at a position spanning a 512 byte block as counted from the call/goto site (callsite assumed to be EOL - works for basic cases at least) then the label won't be found.
#A label preceding a call/goto site can't span a 512 byte boundary as counted from the beginning of the file
#checkoutput produces warnings and errors in ansi-coloured form (both to stdout and a summary in the return value)
#The script should then be adjusted with comments and/or whitespace and checkoutput should be re-run to confirm there are no new boundary-spanning labels.
#checkoutput needs to be run even on previously tested scriptwrapper templates because the final :exit label is beyond the payloads and so could span a 512 Byte block
#checkfile produces warnings and errors in ansi-coloured form (both to stdout and a summary in the return value)
#The script should then be adjusted with comments and/or whitespace and checkfile should be re-run to confirm there are no new boundary-spanning labels.
#checkfile needs to be run even on previously tested scriptwrapper templates because the final :exit label is beyond the payloads and so could span a 512 Byte block
#It is more likely to catch issues if adjustments are made to the initial batch-script code in a template.
#
#cmd allows labels at call sites to span lines with line continuation character ^
@ -121,7 +121,7 @@ namespace eval punk::mix::commandset::scriptwrap {
#This means label-like things could be incorrectly found in other script data - that's partly the point of this check
#Note that we can't filter obviously non-batch-script lines before processing - as the way batch label-scanning works it scans in chunks of 512 bytes so all lines are relevant.
#This means label-like things could be incorrectly found in other script data - that's partly the point of this check.
proc checkoutput {filepath args} {
proc checkfile {filepath args} {
if {![file exists $filepath]} {
error "punk::mix::commandset:scriptwrap error cannot find file '$filepath'"
}
@ -135,7 +135,7 @@ namespace eval punk::mix::commandset::scriptwrap {
set known_opts [dict keys $defaults]
foreach {k v} $args {
if {$k ni $known_opts} {
error "checkoutput error - unknown option '$k'. Known options: $known_opts"
error "checkfile error - unknown option '$k'. Known options: $known_opts"
}
}
set opts [dict merge $defaults $args]
@ -509,11 +509,11 @@ namespace eval punk::mix::commandset::scriptwrap {
set pline_bytes [dict get $plineinfo linelen] ;#includes lf or crlf ending bytes
set pline_start $pline_begin
if {$pline_start != [dict get $plineinfo start]} {
error "checkoutput error: line $p_linenum - calculated start $pline_start not equal to stored start [dict get $plineinfo start]"
error "checkfile error: line $p_linenum - calculated start $pline_start not equal to stored start [dict get $plineinfo start]"
}
set pline_end [expr {$pline_begin + $pline_bytes -1}]
if {$pline_end != [dict get $plineinfo end]} {
error "checkoutput error: line $p_linenum - calculated end $pline_end not equal to stored end [dict get $plineinfo end]"
error "checkfile error: line $p_linenum - calculated end $pline_end not equal to stored end [dict get $plineinfo end]"
}
@ -759,7 +759,7 @@ namespace eval punk::mix::commandset::scriptwrap {
}
return $result
}
#specific filepath to just wrap one script at the tcl-payload or xxx-payload-pre-tcl site
#specific filepath to just wrap one script at the xxx-pre-launch-suprocess site
#scriptset name to substiture multiple scriptset.xxx files at the default locations - or as specified in scriptset.wrapconf
proc multishell {filepath_or_scriptset args} {
set defaults [dict create\
@ -805,13 +805,14 @@ namespace eval punk::mix::commandset::scriptwrap {
set specified_path [file join $startdir $filepath_or_scriptset]
}
set ext [string trim [file extension $filepath_or_scriptset] .]
set allowed_extensions [list wrapconfig tcl ps1 sh bash]
set allowed_extensions [list wrapconfig tcl ps1 sh bash pl]
set extension_langs [list tcl tcl ps1 powershell sh sh bash bash pl perl]
#set allowed_extensions [list tcl]
set found_script 0
if {[file exists $specified_path]} {
set found_script 1
} else {
foreach e $allowed_extensions {
foreach e [concat $allowed_extensions [string toupper $allowed_extensions]] {
if {[file exists $filepath_or_scriptset.$e]} {
set found_script 1
break
@ -992,7 +993,15 @@ namespace eval punk::mix::commandset::scriptwrap {
}
set output_file [file join $output_folder $scriptset.$output_extension]
if {[file exists $output_file]} {
error "wrap_in_multishell: target file $output_file already exists.. aborting"
set fdexisting [open $output_file r]
fconfigure $fdexisting -translation binary
set existing_file_data [read $fdexisting]
close $fdexisting
set objFile_existing [fileline::textinfo new $existing_file_data]
puts stdout "wrap_in_multishell: target file $output_file already exists. File size: [$objFile_existing chunklen] Line count: [$objFile_existing linecount]"
$objFile_existing destroy
error "aborting.."
}
@ -1020,7 +1029,7 @@ namespace eval punk::mix::commandset::scriptwrap {
lappend list_input_files $scriptroot/$scriptset.$ext
}
#todo - split template at each <ext-payload> etc marker and build a dict of parts
#todo - split template at each <ext-*-subprocess> etc marker and build a dict of parts
#hack - process one input
@ -1038,7 +1047,9 @@ namespace eval punk::mix::commandset::scriptwrap {
puts stdout $ln
}
puts stdout "-----------------------------------------------\n"
puts stdout "Target for above data is '$output_file'"
puts stdout "Target for above script data is '$output_file'"
set lang [dict get $extension_langs [string tolower $ext]]
puts stdout "Language of script being wrapped is $lang"
if {$opt_askme} {
set answer [util::askuser "Does this look correct? Y|N"]
if {[string tolower $answer] ne "y"} {
@ -1053,9 +1064,9 @@ namespace eval punk::mix::commandset::scriptwrap {
set existing_payload [list]
foreach ln $template_lines {
if {[string match "#<tcl-payload>*" $ln]} {
if {[string match "#<$lang-pre-launch-subprocess>*" $ln]} {
set start_idx $line_idx
} elseif {[string match "#</tcl-payload>*" $ln]} {
} elseif {[string match "#</$lang-pre-launch-subprocess>*" $ln]} {
set end_idx $line_idx
break
} elseif {$start_idx > 0} {
@ -1068,20 +1079,20 @@ namespace eval punk::mix::commandset::scriptwrap {
incr line_idx
}
if {($start_idx == 0) || ($end_idx == 0)} {
error "wrap_in_multishell was unable to find payload area in template marked with #<tcl-payload> and #</tcl-payload> on separate lines"
error "wrap_in_multishell was unable to find payload area in template marked with #<$lang-pre-launch-subprocess> and #</$lang-pre-launch-subprocess> on separate lines"
}
set existing_string [join $existing_payload \n]
if {[string length [string trim $existing_string]]} {
puts stdout "EXISTING PAYLOAD!!"
puts stdout "EXISTING <$lang-pre-launch-subprocess> PAYLOAD!!"
puts stdout "-----------------------------------------------\n"
puts stdout $existing_string
puts stdout "-----------------------------------------------\n"
error "wrap_in_multishell found existing payload.. aborting."
error "wrap_in_multishell found existing payload for language $lang ... aborting."
#todo - allow overwrite only in files outside of punkshell distribution?
if 0 {
puts stderr "Found existing payload.. overwrite?"
puts stderr "Found existing $lang payload.. overwrite?"
if {$opt_askme} {
set answer [util::askuser "Are you sure you want to replace the tcl payload shown above? Y|N"]
set answer [util::askuser "Are you sure you want to replace the $lang payload shown above? Y|N"]
if {[string tolower $answer] ne "y"} {
puts stderr "mix new aborting due to user response '$answer' (required Y|y to proceed) use -askme 0 to avoid prompts."
return
@ -1100,7 +1111,7 @@ namespace eval punk::mix::commandset::scriptwrap {
puts -nonewline $fdtarget $newscript
close $fdtarget
puts stdout "Wrote script file at $output_file"
set check_result [checkoutput $output_file]
set check_result [checkfile $output_file]
set with_errors ""
set with_warnings ""
set call_labels [list]
@ -1128,7 +1139,7 @@ namespace eval punk::mix::commandset::scriptwrap {
}
}
} else {
puts stderr "Expected output from checkoutput - but got none"
puts stderr "Expected output from checkfile - but got none"
}
#even though chmod might exist on windows - we will leave permissions alone
if {$::tcl_platform(platform) ne "windows"} {

211
src/modules/punk/mix/templates/utility/scriptappwrappers/punk-multishell.cmd

@ -1,13 +1,17 @@
: "[rename set s;proc Hide x {proc $x args {}};Hide :]" "\$(function : {<#pwsh#>})" ^
set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershell;proc Hide x {proc $x args {}}; Hide <#;Hide set;s 1 list]"; set -- : "$@";$1 = @'
: heredoc1 - hide from powershell using @ and squote above. (close sqote for unix shells) ' \
: .bat/.cmd launch section, leading colon hides from cmd, trailing slash hides next line from tcl \
: "[Hide @ECHO; Hide ); Hide (;Hide echo; Hide @REM]#not necessary but can help avoid errs in testing"
: "punk MULTISHELL - shebangless polyglot for Tcl Perl sh bash cmd pwsh powershell" + "[rename set s;proc Hide x {proc $x args {}};Hide :]" + "\$(function : {<#pwsh#>})" + "perlhide" + qw^
set -- "$@" "a=[Hide <#;Hide set;s 1 list]"; set -- : "$@";$1 = @'
: heredoc1 - hide from powershell using @ and squote above. close sqote for unix shells + ' \
: .bat/.cmd launch section, leading colon hides from cmd, trailing slash hides next line from tcl + \
: "[Hide @GOTO; Hide =begin; Hide @REM] #not necessary but can help avoid errs in testing" +
: << 'HEREDOC1B_HIDE_FROM_BASH_AND_SH'
: STRONG SUGGESTION: DO NOT MODIFY FIRST LINE OF THIS SCRIPT - except for first double quoted section.
: shebang line is not required on unix or windows and will reduce functionality and/or portability.
: Even comment lines can be part of the functionality of this script (both on unix and windows) - modify with care.
@GOTO :skip_perl_pod_start ^;
=begin excludeperl
: skip_perl_pod_start
: Continuation char at end of this line and rem with curly-braces used to exlude Tcl from the whole cmd block \
: {
: STRONG SUGGESTION: DO NOT MODIFY FIRST LINE OF THIS SCRIPT. shebang #! line is not required on unix or windows and will reduce functionality and/or portability.
: Even comment lines can be part of the functionality of this script (both on unix and windows) - modify with care.
@REM ############################################################################################################################
@REM THIS IS A POLYGLOT SCRIPT - supporting payloads in Tcl, bash, sh and/or powershelll (powershell.exe or pwsh.exe)
@REM It should remain portable between unix-like OSes & windows if the proper structure is maintained.
@ -19,11 +23,12 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
@REM Due to lack of shebang (#! line) Unix-like systems will probably (hopefully) default to sh if the script is called without an interpreter - but it may depend on the shell in use when called.
@REM If you find yourself really wanting/needing to add a shebang line - do so on the basis that the script will exist on unix-like systems only.
@SETLOCAL EnableExtensions EnableDelayedExpansion
@SET "validshells= ^(10^) 'pwsh' ^(11^) 'sh' (^12^) 'bash' (^13^) 'tclsh'"
@SET "validshells= ^(10^) 'pwsh' ^(11^) 'sh' (^12^) 'bash' (^13^) 'tclsh' (^14^) 'perl'"
@SET "shells[10]=pwsh"
@SET "shells[11]=sh"
@set "shells[12]=bash"
@SET "shells[13]=tclsh"
@SET "shells[14]=perl"
: <nextshell>
@SET "nextshell=13"
: </nextshell>
@ -49,16 +54,16 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
@REM -- Due to this issue -seemingly trivial edits of the batch file section can break the script! (for Windows anyway)
@REM -- Even something as simple as adding or removing an @REM
@REM -- From within punkshell - use:
@REM -- pmix scriptwrap.checkoutput <filepath>
@REM -- pmix scriptwrap.checkfile <filepath>
@REM -- to check your templates or final wrapped scripts for byte boundary issues
@REM -- It will report any labels that are on boundaries
@REM -- This is why the nextshell value above is a 2 digit key instead of a string - so that editing the value doesn't change the byte offsets.
@REM -- Editing your sh,bash,tcl,pwsh payloads is much less likely to cause an issue. There is the possibility of the final batch :exit_multishell label spanning a boundary - so testing using pmix scriptwrap.checkoutput is still recommended.
@REM -- Editing your sh,bash,tcl,pwsh payloads is much less likely to cause an issue. There is the possibility of the final batch :exit_multishell label spanning a boundary - so testing using pmix scriptwrap.checkfile is still recommended.
@REM -- Alternatively, as you should do anyway - test the final script on windows
@REM -- Aside from adding comments/whitespace to tweak the location of labels - you can try duplicating the label (e.g just add the label on a line above) but this is not guaranteed to work in all situations.
@REM -- '@REM' is a safer comment mechanism than a leading colon - which is used sparingly here.
@REM -- A colon anywhere in the script that happens to land on a 512 Byte boundary (from file start or from a callsite) could be misinterpreted as a label
@REM -- It is unknown what versions of cmd interpreters behave this way - and pmix scriptwrap.checkoutput doesn't check all such boundaries.
@REM -- It is unknown what versions of cmd interpreters behave this way - and pmix scriptwrap.checkfile doesn't check all such boundaries.
@REm -- For this reason, batch labels should be chosen to be relatively unlikely to collide with other strings in the file, and simple names such as :exit or :end should probably be avoided
@REM ############################################################################################################################
@REM -- custom windows payloads should be in powershell,tclsh (or sh/bash if available) code sections
@ -104,7 +109,7 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
@ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
@ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
@ECHO Next >> "%vbsGetPrivileges%"
@ECHO UAC.ShellExecute "%~dp0%~n0.cmd", args, "", "runas", 1 >> "%vbsGetPrivileges%"
@ECHO UAC.ShellExecute "%~dp0%~n0%~x0", args, "", "runas", 1 >> "%vbsGetPrivileges%"
@ECHO Launching script in new windows due to administrator elevation
@"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
@EXIT /B
@ -124,7 +129,7 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
@if not exist "%~dp0%~n0.ps1" (
@SET need_ps1=1
) ELSE (
fc "%~dp0%~n0.cmd" "%~dp0%~n0.ps1" >nul || goto different
fc "%~dp0%~n0%~x0" "%~dp0%~n0.ps1" >nul || goto different
@REM @ECHO "files same"
@SET need_ps1=0
)
@ -134,7 +139,7 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
@SET need_ps1=1
:pscontinue
@IF !need_ps1!==1 (
COPY "%~dp0%~n0.cmd" "%~dp0%~n0.ps1" >NUL
COPY "%~dp0%~n0%~x0" "%~dp0%~n0.ps1" >NUL
)
@REM avoid using CALL to launch pwsh,tclsh etc - it will intercept some args such as /?
@IF "!shells[%nextshell%]!"=="pwsh" (
@ -145,7 +150,8 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
REM ECHO pwshtest_exitcode !pwshtest_exitcode!
REM fallback to powershell if pwsh failed
IF !pwshtest_exitcode!==0 (
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted; "%~dp0%~n0.ps1" %arglist% & SET task_exitcode=!errorlevel!
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted; "%~dp0%~n0.ps1" %arglist%
SET task_exitcode=!errorlevel!
) ELSE (
REM CALL powershell -nop -nol -c write-host powershell-found
REM powershell -nop -nol -file "%~dp0%~n0.ps1" %*
@ -156,21 +162,25 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
IF "!shells[%nextshell%]!"=="bash" (
CALL :getWslPath %winpath% wslpath
REM ECHO wslfullpath "!wslpath!%fname%"
!shells[%nextshell%]! "!wslpath!%fname%" %arglist% & SET task_exitcode=!errorlevel!
!shells[%nextshell%]! "!wslpath!%fname%" %arglist%
SET task_exitcode=!errorlevel!
) ELSE (
REM probably tclsh or sh
IF NOT "x%keyRemoved%"=="x%validshells%" (
REM sh on windows uses /c/ instead of /mnt/c - at least if using msys. Todo, review what is the norm on windows with and without msys2,cygwin,wsl
REM and what logic if any may be needed. For now sh with /c/xxx seems to work the same as sh with c:/xxx
!shells[%nextshell%]! "%~dp0%fname%" %arglist% & SET task_exitcode=!errorlevel!
!shells[%nextshell%]! "%~dp0%fname%" %arglist%
SET task_exitcode=!errorlevel!
) ELSE (
ECHO %fname% has invalid nextshell value ^(%nextshell%^) !shells[%nextshell%]! valid options are %validshells%
SET task_exitcode=66
@REM boundary padding
GOTO :exit_multishell
)
)
)
@REM batch file library functions
@REM boundary padding
@GOTO :endlib
:getWslPath
@ -227,6 +237,7 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
)
@EXIT /B
@REM boundary padding
@REM boundary padding
:getNormalizedScriptTail
@SETLOCAL
@SET "result=%~nx0"
@ -245,6 +256,8 @@ set -- "$@" "a=[list shebangless punk MULTISHELL tclsh sh bash cmd pwsh powershe
@REM note that %~nx1 does not preserve case of provided path - hence the name 'normalized'
@REM boundary padding
@REM boundary padding
@REM boundary padding
@REM boundary padding
@SETLOCAL
@CALL :stringContains %~1 "\" hasBackSlash
@CALL :stringContains %~1 "/" hasForwardSlash
@ -380,9 +393,15 @@ namespace eval ::punk::multishell {
# -- --- --- --- --- --- --- --- --- --- --- ---
#<tcl-payload>
#</tcl-payload>
#<tcl-pre-launch-subprocess>
#</tcl-pre-launch-subprocess>
#<tcl-launch-subprocess>
#</tcl-launch-subproces>
#<tcl-post-launch-subprocess>
#</tcl-post-launch-subproces>
# -- --- --- --- --- --- --- --- --- --- --- ---
@ -414,33 +433,33 @@ if false==false # else {
# -- leave as is if all that is required is launching the Tcl payload"
# --
# -- Note that sh/bash script isn't called when running a .bat/.cmd from cmd.exe on windows by default
# -- adjust @call line above ... to something like @call sh ... @call bash .. or @call env sh ... etc as appropriate
# -- adjust the %nextshell% value above
# -- if sh/bash scripting needs to run on windows too.
# --
# ## ### ### ### ### ### ### ### ### ### ### ### ### ###
# -- --- --- --- --- --- --- --- --- --- --- --- --- ---begin sh Payload
exitcode=0
#printf "start of bash or sh code"
#<shell-payload-pre-tcl>
#</shell-payload-pre-tcl>
#<shell-pre-launch-subprocess>
#</shell-pre-launch-subprocess>
# -- --- --- --- --- --- --- ---
#<shell-launch-tcl>
exitcode=0 ;#default assumption
#<shell-launch-subprocess>
#-- sh/bash launches Tcl here instead of shebang line at top
#-- use exec to use exitcode (if any) directly from the tcl script
#exec /usr/bin/env tclsh "$0" "$@"
#-- alternative - can run sh/bash script after the tcl call.
/usr/bin/env tclsh "$0" "$@"
exitcode=$?
#echo "tcl exitcode: ${exitcode}"
#echo "sh/bash reporting tcl exitcode: ${exitcode}"
#-- override exitcode example
#exit 66
#</shell-launch-tcl>
#</shell-launch-subprocess>
# -- --- --- --- --- --- --- ---
#<shell-payload-post-tcl>
#</shell-payload-post-tcl>
#<shell-post-launch-subprocess>
#</shell-post-launch-subproces>
#printf "sh/bash done \n"
@ -448,7 +467,57 @@ exitcode=$?
#------------------------------------------------------
fi
exit ${exitcode}
# end hide sh/bash block from Tcl
# ## ### ### ### ### ### ### ### ### ### ### ### ### ###
# -- Perl script section
# -- leave the script below as is, if all that is required is launching the Tcl payload"
# --
# -- Note that perl script isn't called by default when simply running this script by name
# -- adjust the nextshell value at the top of the script to point to perl
# --
# ## ### ### ### ### ### ### ### ### ### ### ### ### ###
=cut
#!/user/bin/perl
# -- --- --- --- --- --- --- --- --- --- --- --- --- ---begin perl Payload
my $exit_code = 0;
#use ExtUtils::Installed;
#my $installed = ExtUtils::Installed->new();
#my @modules = $installed->modules();
#print "Modules:\n";
#foreach my $m (@modules) {
# print "$m\n";
#}
# -- --- ---
my $scriptname = $0;
print "perl $scriptname\n";
my $i =1;
foreach my $a(@ARGV) {
print "Arg # $i: $a\n";
}
#<perl-pre-launch-subprocess>
#</perl-pre-launch-subprocess>
# -- --- --- --- --- --- --- ---
#<perl-launch-subprocess>
$exit_code=system("tclsh", $scriptname, @ARGV);
#print "perl reporting tcl exitcode: $exit_code";
#</perl-launch-subprocess>
# -- --- --- --- --- --- --- ---
#<perl-post-launch-subprocess>
#</perl-post-launch-subprocess>
# -- --- --- --- --- --- --- --- --- --- --- --- --- ---end perl Payload
exit $exit_code;
__END__
# end hide sh/bash/perl block from Tcl
# This comment with closing brace should stay in place whether if commented or not }
#------------------------------------------------------
# begin hide powershell-block from Tcl - only needed if Tcl didn't exit or return above
@ -460,9 +529,76 @@ if 0 {
# -- Do not edit if current file is the .ps1
# -- Edit the corresponding .cmd and it will autocopy
# -- unbalanced braces { } here *even in comments* will cause problems if there was no Tcl exit or return above
# -- custom script should generally go below the begin_powershell_payload line
# ## ### ### ### ### ### ### ### ### ### ### ### ### ###
function GetScriptName { $myInvocation.ScriptName }
$scriptname = getScriptName
$scriptname = GetScriptName
function GetDynamicParamDictionary {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true, Mandatory=$true)]
[string] $CommandName
)
begin {
# Get a list of params that should be ignored (they're common to all advanced functions)
$CommonParameterNames = [System.Runtime.Serialization.FormatterServices]::GetUninitializedObject([type] [System.Management.Automation.Internal.CommonParameters]) |
Get-Member -MemberType Properties |
Select-Object -ExpandProperty Name
}
process {
# Create the dictionary that this scriptblock will return:
$DynParamDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
# Convert to object array and get rid of Common params:
(Get-Command $CommandName | select -exp Parameters).GetEnumerator() |
Where-Object { $CommonParameterNames -notcontains $_.Key } |
ForEach-Object {
$DynamicParameter = New-Object System.Management.Automation.RuntimeDefinedParameter (
$_.Key,
$_.Value.ParameterType,
$_.Value.Attributes
)
$DynParamDictionary.Add($_.Key, $DynamicParameter)
}
# Return the dynamic parameters
return $DynParamDictionary
}
}
# GetDynamicParamDictionary
# - This can make it easier to share a single set of param definitions between functions
# - sample usage
#function ParameterDefinitions {
# param(
# [Parameter(Mandatory)][string] $myargument
# )
#}
#function psmain {
# [CmdletBinding()]
# param()
# dynamicparam { GetDynamicParamDictionary ParameterDefinitions }
# process {
# #called once with $PSBoundParameters dictionary
# #can be used to validate arguments, or set a simpler variable name for access
# switch ($PSBoundParameters.keys) {
# 'myargumentname' {
# Set-Variable -Name $_ -Value $PSBoundParameters."$_"
# }
# #...
# }
# foreach ($boundparam in $PSBoundParameters.GetEnumerator()) {
# #...
# }
# }
# end {
# #Main function logic
# Write-Host "myargumentname value is: $myargumentname"
# #myotherfunction @PSBoundParameters
# }
#}
#psmain @args
# -- --- --- --- --- --- --- --- --- --- --- --- --- ---begin powershell Payload
#"Timestamp : {0,10:yyyy-MM-dd HH:mm:ss}" -f $(Get-Date) | write-host
#"Script Name : {0}" -f $scriptname | write-host
@ -470,22 +606,22 @@ $scriptname = getScriptName
#"powershell args : {0}" -f ($args -join ", ") | write-host
# -- --- --- ---
#<powershell-payload-pre-tcl>
#</powershell-payload-pre-tcl>
#<powershell-pre-launch-subprocess>
#</powershell-pre-launch-subprocess>
# -- --- --- --- --- --- --- ---
#<powershell-launch-tcl>
#<powershell-launch-subprocess>
tclsh $scriptname $args
#</powershell-launch-tcl>
#"powershell reporting exitcode: {0}" -f $LASTEXITCODE | write-host
#</powershell-launch-subprocess>
# -- --- --- --- --- --- --- ---
#<powershell-payload-post-tcl>
#</powershell-payload-post-tcl>
#<powershell-post-launch-subprocess>
#</powershell-post-launch-subprocess>
# -- --- --- --- --- --- --- --- --- --- --- --- --- ---end powershell Payload
#"powershell reporting exitcode: {0}" -f $LASTEXITCODE | write-host
Exit $LASTEXITCODE
# heredoc2 for powershell to ignore block below
$1 = @'
@ -509,6 +645,7 @@ $1 = @'
# -- powershell multiline comment
#>
<#
no script engine should try to run me
# id:tailblock1
# <ctrl-z>


2
src/scriptapps/fetchruntime.ps1

@ -1,5 +1,5 @@
$url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclkit86bi.exe"
$output = "runtime\tclkit86bi.exe"
$output = "$(join-path $PSScriptRoot "..\src\runtime\tclkit86bi.exe")"
if (-not(Test-Path -Path $output -PathType Leaf)) {
try {

6
src/scriptapps/punk87.tcl

@ -1,6 +1,6 @@
puts stdout "launching punk87"
#puts stdout "launching punk87"
set dirname [file dirname [info script]]
set dirname [file dirname [file normalize [info script]]]
if {[file tail $dirname] eq "bin"} {
if {[file exists [file join $dirname ../src/punk86.vfs/main.tcl]]} {
#tclsh [file join $dirname ../src/punk86.vfs/main.tcl] {*}$::argv
@ -11,5 +11,5 @@ if {[file tail $dirname] eq "bin"} {
} else {
puts stderr "punk87 launch script must be run from the punk bin folder"
}
puts stdout "-done-"
#puts stdout "-done-"

Loading…
Cancel
Save