#The user can always use exec for different process error semantics (they don't get exitcode with exec)
#The user can always use exec for different process error semantics (they don't get exitcode with exec)
namespace eval shellrun {
namespace eval shellrun {
variable PUNKARGS
variable runout
variable runout
variable runerr
variable runerr
@ -127,19 +128,35 @@ namespace eval shellrun {
#todo - investigate cause of punk86 run hanging sometimes. An 'after 500' before exit in the called script fixes the issue. punk87 doesn't seem to be affected.
#todo - investigate cause of punk86 run hanging sometimes. An 'after 500' before exit in the called script fixes the issue. punk87 doesn't seem to be affected.
lappend PUNKARGS [list {
@id -id ::shellrun::run
@leaders -min 0 -max 0
@opts
-nonewline -type none
-tcl -type none -default 0
-debug -type none -default 0
--timeout= -type integer
@values -min 1 -max -1
cmdname -type string
cmdarg -type any -multiple 1 -optional 1
}]
proc run {args} {
proc run {args} {
#set_last_run_display [list]
#set_last_run_display [list]
set splitargs [get_run_opts $args]
#set splitargs [get_run_opts $args]
set runopts [dict get $splitargs runopts]
#set runopts [dict get $splitargs runopts]
set runoptslong [dict get $splitargs runoptslong]
#set runoptslong [dict get $splitargs runoptslong]
set cmdargs [dict get $splitargs cmdargs]
#set cmdargs [dict get $splitargs cmdargs]
set argd [punk::args::parse $args withid ::shellrun::run]
lassign [dict values $argd] leaders opts values received
if {"-nonewline" in $runopts} {
if {[dict exists $received "-nonewline"]} {
set nonewline 1
set nonewline 1
} else {
} else {
set nonewline 0
set nonewline 0
}
}
#review nonewline does nothing here..
set idlist_stderr [list]
set idlist_stderr [list]
#we leave stdout without imposed ansi colouring - because the source may be colourised and because ansi-wrapping a stream at whatever boundaries it comes in at isn't a really nice thing to do.
#we leave stdout without imposed ansi colouring - because the source may be colourised and because ansi-wrapping a stream at whatever boundaries it comes in at isn't a really nice thing to do.
#stderr might have source colouring - but it usually doesn't seem to, and the visual distiction of red stderr can be very handy for the run command.
#stderr might have source colouring - but it usually doesn't seem to, and the visual distiction of red stderr can be very handy for the run command.
set contents_has_ansi [punk::ansi::ta::detect $contents]
if {$opt_ansibase ne ""} {
if {$contents_has_ansi} {
set contents [punk::ansi::ansiwrap -rawansi $opt_ansibase $contents]
} else {
set contents "$opt_ansibase$contents\x1b\[0m"
set contents_has_ansi 1
}
}
set cwidth $actual_contentwidth
set cwidth $actual_contentwidth
if {$opt_pad} {
if {$opt_pad} {
set paddedcontents [textblock::pad $contents -known_blockwidth $cwidth -which $pad -within_ansi 1] ;#autowidth to width of content (should match cache_patternwidth)
set paddedcontents [textblock::pad $contents -known_blockwidth $cwidth -which $pad -within_ansi 1] ;#autowidth to width of content (should match cache_patternwidth)