diff --git a/src/modules/shellrun-0.1.tm b/src/modules/shellrun-0.1.tm index 5a78b3fd..7f05193f 100644 --- a/src/modules/shellrun-0.1.tm +++ b/src/modules/shellrun-0.1.tm @@ -29,8 +29,8 @@ namespace eval shellrun { #we provide -nonewline even for 'run' even though run doesn't deliver stderr or stdout to the tcl return value #This is for compatibility with other runX commands, and the difference is also visible when calling from repl. - set known_runopts [list "-echo" "-e" "-nonewline" "-n"] - set aliases [list "-e" "-echo" "-echo" "-echo" "-n" "-nonewline" "-nonewline" "-nonewline"] ;#include map to self + set known_runopts [list "-echo" "-e" "-nonewline" "-n" "-tcl"] + set aliases [list "-e" "-echo" "-echo" "-echo" "-n" "-nonewline" "-nonewline" "-nonewline" "-tcl" "-tcl"] ;#include map to self set runopts [list] set cmdargs [list] set idx_first_cmdarg [lsearch -not $arglist "-*"] @@ -67,8 +67,12 @@ namespace eval shellrun { # what we probably want to do is 'aside' that transform for runxxx commands only. #lappend idlist_stderr [shellfilter::stack::add stderr ansiwrap -settings {-colour {red bold}}] + set callopts [dict create] + if {"-tcl" in $runopts} { + dict set callopts -tclscript 1 + } #--------------------------------------------------------------------------------------------- - set exitinfo [shellfilter::run $cmdargs -teehandle punk -inbuffering none -outbuffering none ] + set exitinfo [shellfilter::run $cmdargs {*}$callopts -teehandle punk -inbuffering none -outbuffering none ] #--------------------------------------------------------------------------------------------- foreach id $idlist_stderr { @@ -121,8 +125,13 @@ namespace eval shellrun { set stderr_stackid [shellfilter::stack::add stderr var -action float-locked -settings {-varname ::shellrun::runerr}] } + set callopts "" + if {"-tcl" in $runopts} { + append callopts " -tclscript 1" + } + #shellfilter::run [lrange $args 1 end] -teehandle punk -outchan stdout -inbuffering none -outbuffering none -stdinhandler ::repl::repl_handler - set exitinfo [shellfilter::run $cmdargs -teehandle punk -inbuffering none -outbuffering none ] + set exitinfo [shellfilter::run $cmdargs {*}$callopts -teehandle punk -inbuffering none -outbuffering none ] flush stderr flush stdout @@ -134,7 +143,11 @@ namespace eval shellrun { if {[dict exists $exitinfo error]} { #we must raise an error. #todo - check errorInfo makes sense.. return -code? tailcall? - error [dict get $exitinfo error] + # + set msg "" + append msg [dict get $exitinfo error] + append msg "\n(add -tcl option to run as a tcl command/script instead of an external command)" + error $msg } set chunklist [list] @@ -211,6 +224,10 @@ namespace eval shellrun { set nonewline 0 } + set callopts "" + if {"-tcl" in $runopts} { + append callopts " -tclscript 1" + } if {"-echo" in $runopts} { set stderr_stackid [shellfilter::stack::add stderr tee_to_var -action float-locked -settings {-varname ::shellrun::runerr}] set stdout_stackid [shellfilter::stack::add stdout tee_to_var -action float-locked -settings {-varname ::shellrun::runout}] @@ -220,7 +237,7 @@ namespace eval shellrun { } - set exitinfo [shellfilter::run $cmdargs -teehandle punk -inbuffering none -outbuffering none -stdinhandler ::repl::repl_handler] + set exitinfo [shellfilter::run $cmdargs {*}$callopts -teehandle punk -inbuffering none -outbuffering none -stdinhandler ::repl::repl_handler] shellfilter::stack::remove stderr $stderr_stackid shellfilter::stack::remove stdout $stdout_stackid @@ -326,8 +343,12 @@ namespace eval shellrun { set stdout_stackid [shellfilter::stack::add stdout var -action float-locked -junction 1 -settings {-varname ::shellrun::runout}] } + set callopts "" + if {"-tcl" in $runopts} { + append callopts " -tclscript 1" + } #set exitinfo [shellfilter::run $cmdargs -teehandle punk -inbuffering none -outbuffering none -stdinhandler ::repl::repl_handler] - set exitinfo [shellfilter::run $cmdargs -teehandle punk -inbuffering none -outbuffering none] + set exitinfo [shellfilter::run $cmdargs {*}$callopts -teehandle punk -inbuffering none -outbuffering none] shellfilter::stack::remove stdout $stdout_stackid shellfilter::stack::remove stderr $stderr_stackid