Browse Source

flush stderr/stdout in run functions

master
Julian Noble 2 years ago
parent
commit
e906a1864c
  1. 20
      src/punk86.vfs/lib/app-punk/repl.tcl

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

@ -613,7 +613,7 @@ proc do_runraw {commandline} {
foreach o $runopts {
if {$o ni $known_runopts} {
error "runout: Unknown runoption $o"
error "runraw: Unknown runoption $o"
}
}
set runopts [lmap o $runopts {dict get $aliases $o}]
@ -670,6 +670,9 @@ know {[lindex $args 0] eq "run"} {
set id_err [shellfilter::stack::add stderr ansiwrap -settings {-colour {red bold}}]
set exitinfo [shellfilter::run $cmdargs -teehandle punk -inbuffering none -outbuffering none ]
shellfilter::stack::remove stderr $id_err
flush stderr
flush stdout
set c [shellfilter::ansi::+ green]
set n [shellfilter::ansi::+]
@ -718,6 +721,12 @@ know {[lindex $args 0] eq "runout"} {
error [dict get $exitinfo error]
}
flush stderr
flush stdout
set lastoutchar [string range $::repl::output_stdout end-1 end]
#exitcode not part of return value - colourcode appropriately
set n [shellfilter::ansi::+]
set code [dict get $exitinfo exitcode]
@ -742,7 +751,7 @@ know {[lindex $args 0] eq "runerr"} {
set cmdargs [lrange $args $idx_first_cmdarg end]
foreach o $runopts {
if {$o ni $known_runopts} {
error "runout: Unknown runoption $o"
error "runerr: Unknown runoption $o"
}
}
set runopts [lmap o $runopts {dict get $aliases $o}]
@ -756,6 +765,9 @@ know {[lindex $args 0] eq "runerr"} {
shellfilter::stack::remove stderr $stderr_stackid
flush stderr
flush stdout
#we raise an error because an error during calling is different to collecting stderr from a command, and the caller should be able to wrap in a catch
# to determine something other than just a nonzero exit code or output on stderr.
if {[dict exists $exitinfo error]} {
@ -788,7 +800,7 @@ know {[lindex $args 0] eq "runx"} {
set cmdargs [lrange $args $idx_first_cmdarg end]
foreach o $runopts {
if {$o ni $known_runopts} {
error "runout: Unknown runoption $o"
error "runx: Unknown runoption $o"
}
}
set runopts [lmap o $runopts {dict get $aliases $o}]
@ -812,6 +824,8 @@ know {[lindex $args 0] eq "runx"} {
set ::repl::output ""
flush stderr
flush stdout
#set x [shellfilter::stack::add stdout var -action sink-locked -settings {-varname ::repl::runxoutput}]
set pretty ""

Loading…
Cancel
Save