#based on wiki.. https://wiki.tcl-lang.org/page/source+with+args
#added support for ?-encoding name? and other options of Tcl source command under assumption they come pairs before the filename
# review? seems unlikely source command will ever accept solo options. It would make complete disambiguation impossible when passing additional args as we are doing here.
set cmdargs [list]
set scriptargs [list]
set inopts 0
set i 0
foreach a $args {
if {$i eq [llength $args]-1} {
#reached end without finding end of opts
#must be file - even if it does match -* ?
break
}
if {!$inopts} {
if {[string match -* $a]} {
set inopts 1
} else {
#leave loop at first nonoption - i should be index of file
break
}
} else {
#leave for next iteration to check
set inopts 0
}
incr i
}
set cmdargs [lrange $args 0 $i]
set scriptargs [lrange $args $i+1 end]
set argv $::argv
set argc $::argc
set ::argv $scriptargs
set ::argc [llength $scriptargs]
set code [catch {uplevel [list source {*}$cmdargs]} return]
Documents and help files (for the repository website)
These are html, markdown, manfiles etc which live within src/embedded and are intended to be checked into source control so they can form part of the online documentation available when browsing the repository.
These files shouldn't be modified directly as they are built from the files in the src/doc folder
Create multishell scripts from your .tcl .sh and .ps1 scripts that are stored here.
Use the pmix wrap functions to generate a multishell .cmd file from your scripts.
This .cmd is a 'polyglot' script - it should run when called from any of the target interpreters.
A multishell .cmd file is a cross-platform script that can easily be run on Windows and unix-like platforms.
The .cmd extension is primarily a convenience so that it can be run easily by name on windows but it is ok to either leave it as that on other platforms, or rename it appropriately.
On unix-like platforms it can be called with a bourne shell such as sh or bash.
On windows, it can also be called with sh or bash if they are available - but the usual method would be to run it under cmd.exe initially just by opening a cmd prompt and running it.
This will run some windows batch script to automatically generate a corresponding .ps1 file and execution will switch to powershell 5 or powershell 7 (pwsh) if available.
Subsequently the command can be run directly from powershell.
Whether called from Bourne shell, or cmd.exe or powershell - the usual payload would be your wrapped Tcl code - but it's also possible for powershell or sh/bash to be the primary payload script.
Any of these languages could easily be used to detect and launch other scripts/utilities that you may distribute with your app.
Any pkgIndex based libraries that are external to the project but which the project owners wish to distribute with the project and keep under source control.
These should generally be kept to a minimum
- with dependency and version numbers being tracked instead; along with the provision of a mechanism for the project end-users to update.
puts stderr "cksum_path is not yet able to cksum ACLs"
return
}
set opt_cksum_meta [dict get $opts -cksum_meta]
if {$opt_cksum_meta} {
} else {
if {[file type $path] ne "file"} {
puts stderr "cksum_path doesn't yet support a content-only cksum of a folder structure. Currently only files supported without metadata. For folders use cksum_path -cksum_meta 1"
return [list error unsupported opts $opts]
}
}
set opt_use_tar [dict get $opts -use_tar]
if {$opt_use_tar} {
package require tar ;#from tcllib
} else {
if {[file type $path] eq "directory"} {
puts stderr "cksum_path doesn't yet support -use_tar 0 for folders"
return [list error unsupported opts $opts]
}
}
if {$path eq $base} {
#attempting to cksum at root/volume level of a filesystem.. extra work
puts stderr "cksum_path doesn't yet support cksum of entire volume. (todo)"
return [list error unsupported opts $opts]
}
set cksum ""
if {$opt_use_tar} {
set target [file tail $path]
set tmplocation [tmpdir]
set archivename $tmplocation/[tmpfile].tar
cd $base ;#cd is process-wide.. keep cd in effect for as small a scope as possible. (review for thread issues)
#temp emission to stdout.. todo - repl telemetry channel
puts stdout "cksum_path: creating temporary tar archive at: $archivename .."