Browse Source

fix punk::exitcode function arguments and make runx compatible with it

master
Julian Noble 2 years ago
parent
commit
ea976e6b48
  1. 3
      src/modules/punk-0.1.tm
  2. 3
      src/modules/shellrun-0.1.tm
  3. 5
      src/punk86.vfs/lib/app-punk/repl.tcl

3
src/modules/punk-0.1.tm

@ -311,7 +311,8 @@ namespace eval punk {
#sh style true/false for process exitcode. 0 is true - everything else false
proc exitcode {c} {
proc exitcode {args} {
set c [lindex $args 0]
if {[string is integer -strict $c]} {
#return [expr {$c == 0}]
#return true/false to make it clearer we are outputting tcl-boolean inverse mapping from the shell style 0=true

3
src/modules/shellrun-0.1.tm

@ -372,6 +372,7 @@ namespace eval shellrun {
if {$nonewline} {
return [list stdout [string trimright $::shellrun::runout \r\n] stderr [string trimright $::shellrun::runerr \r\n] {*}$exitinfo]
}
return [list stdout $::shellrun::runout stderr $::shellrun::runerr {*}$exitinfo]
#always return exitinfo $code at beginning of dict (so that punk unknown can interpret the exit code as a unix-style bool if double evaluated)
return [list {*}$exitinfo stdout $::shellrun::runout stderr $::shellrun::runerr]
}
}

5
src/punk86.vfs/lib/app-punk/repl.tcl

@ -420,10 +420,11 @@ know {[regexp {^([0-9]+)\.\.([0-9]+)$} [lindex $args 0] -> from to]} {
}
#handle process return dict of form {exitcode num etc blah}
#ie when the return result as a whole is treated as a command
#exitcode must be the first key
know {[lindex $args 0 0] eq "exitcode"} {
set c [lindex $args 0 1]
uplevel 1 [list exitcode $c]
#set c [lindex $args 0 1]
uplevel 1 [list exitcode {*}[lrange [lindex $args 0] 1 end]]
}

Loading…
Cancel
Save