#the list_element_info analysys left in for debugging in case the quoting/internal rep mechanism in Tcl changes from version to version
#we hopefully don't need to check the "wouldescape" "wouldescape" member of listinfo if we've been careful enough
#----------
foreach w $cmdlineparts {
#set wordinfo [dict get $listinfo $i]
#if {[dict get $wordinfo wouldbrace] && [dict get $wordinfo head_tail_names] eq {lbrace rbrace}} {
# append cmdline [string range $w 1 end-1]
#} else {
append cmdline $w
#}
append cmdline " "
incr i
}
# -----------------
#puts stdout --1>$cmdline
#All this mucking about is because:
#cmdline could be something like: cmd /c echo x\"x^b
#when represented as a list - but we just want it as: cmd /c echo x"x^b
# -----------------
set cmdline [string range $cmdline 0 end-1]
shellrun::tw_run $cmdline
}
proc run {args} {
proc run {args} {
set_last_run_display [list]
set_last_run_display [list]
@ -546,7 +609,7 @@ namespace eval shellrun {
proc repl_runraw {args} {
proc repl_runraw {args} {
error "runraw: only available in repl as direct call - not from script"
error "runraw: only available in repl as direct call - not from script"
}
}
#we can only call runraw with a single (presumably braced) string if we want to use it from both repl and tcl scripts
#we can only call runraw with a single (presumably braced) string if we want to use it from both repl and tcl scripts (why? todo with unbalanced quotes/braces?)
proc runraw {commandline} {
proc runraw {commandline} {
#runraw fails as intended - because we can't bypass exec/open interference quoting :/
#runraw fails as intended - because we can't bypass exec/open interference quoting :/
set_last_run_display [list]
set_last_run_display [list]
@ -669,11 +732,27 @@ namespace eval shellrun {
}
}
namespace eval shellrun {
namespace eval shellrun {
proc twapi_exec {cmdline} {
proc twapi_exec {cmdline args} {
package require twapi
set psinfo [twapi::create_process {} -cmdline $cmdline {*}$args]
}
proc tw_run {cmdline} {
#twapi::create_file to redirect?
package require twapi
package require twapi
twapi::create_process {} -cmdline $cmdline
set psinfo [twapi::create_process {} -cmdline $cmdline -returnhandles 1]
lassign $psinfo _pid _tid hpid htid
set waitresult [twapi::wait_on_handle $hpid -wait -1]