My experience in tcl is limited to random activities. However, the following links starting with the answer in @jk's answer led me to this page , which discusses the errorCode variable and related things that may be useful for this circumstance. Here is a brief example demonstrating the use of errorCode:
TCL:
set ret_val [catch { exec /bin/bash /path/to/bash_script }] set errc $errorCode set ret_val [lindex [split $errc " " ] 2] puts $ret_val
bash_script as above:
#!/bin/bash exit 42
which led to the exit:
42
source share