Browse Source

make runx output more consistent

master
Julian Noble 1 year ago
parent
commit
7e87ecb7d5
  1. 40
      src/modules/shellrun-0.1.tm

40
src/modules/shellrun-0.1.tm

@ -417,8 +417,6 @@ namespace eval shellrun {
}
#set x [shellfilter::stack::add stdout var -action sink-locked -settings {-varname ::repl::runxoutput}]
set chunklist [list]
lappend chunklist [list "info" "[a+ white bold]stdout[a+]"]
set chunk ""
if {[string length $::shellrun::runout]} {
@ -427,13 +425,19 @@ namespace eval shellrun {
} else {
set o $::shellrun::runout
}
append chunk $o
set chunk $o
}
set chunklist [list]
lappend chunklist [list "info" " "]
lappend chunklist [list "result" stdout]
lappend chunklist [list "info" "[a+ white bold]stdout[a+]"]
lappend chunklist [list result $chunk]
lappend chunklist [list "info" " "]
set chunk "[a+ red bold]stderr[a+]"
lappend chunklist [list "info" $chunk]
lappend chunklist [list "result" $chunk]
lappend chunklist [list "info" stderr]
set chunk ""
if {[string length $::shellrun::runerr]} {
@ -442,7 +446,7 @@ namespace eval shellrun {
} else {
set e $::shellrun::runerr
}
append chunk $e
set chunk $e
}
#stderr is part of the result
lappend chunklist [list "resulterr" $chunk]
@ -456,10 +460,28 @@ namespace eval shellrun {
if {$code == 0} {
set c [a+ green]
} else {
set c [a+ white bold]
set c [a+ yellow bold]
}
lappend chunklist [list "info" " "]
lappend chunklist [list "result" exitcode]
lappend chunklist [list "info" "exitcode $code"]
lappend chunklist [list "result" "$c$code$n"]
set exitdict [list exitcode $code]
} elseif [[dict exists $exitinfo result]] {
# presumably from a -tcl call
set val [dict get $exitinfo result]
lappend chunklist [list "info" " "]
lappend chunklist [list "result" result]
lappend chunklist [list "info" result]
lappend chunklist [list "result" $val]
set exitdict [list result $val]
} else {
#review - if no exitcode or result. then what is it?
lappend chunklist [list "info" exitinfo]
set c [a+ yellow bold]
lappend chunklist [list result "$c$exitinfo$n"]
set exitdict [list exitinfo $exitinfo]
}
lappend chunklist [list result "$c$exitinfo$n"]
set_last_run_display $chunklist
@ -468,10 +490,10 @@ namespace eval shellrun {
if {$nonewline} {
return [list {*}$exitinfo stdout [string trimright $::shellrun::runout \r\n] stderr [string trimright $::shellrun::runerr \r\n]]
return [list {*}$exitdict stdout [string trimright $::shellrun::runout \r\n] stderr [string trimright $::shellrun::runerr \r\n]]
}
#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]
return [list {*}$exitdict stdout $::shellrun::runout stderr $::shellrun::runerr]
}
#an experiment

Loading…
Cancel
Save