I try to retrieve the result from $_ inside a tcsh script itself sourced by another tcsh script (I'll refer to them respectively as the inner and outer script). But $_ is not set with the value I expect (being the last command executed). outer code:#!/usr/bin/tcshset lastCmd0 = ($_)echo ${lastCmd0}echo $0source innerecho enOuterinner code:#!/usr/bin/tcshset lastCmd1 = ($_)echo ${lastCmd1}echo $0echo endInnerHere are the output when calling source outer:source outer tcshsource outer tcshendInnerenOuterQ 1 Why is there two source outer, the second one shoudn't be source inner?Here are the output when calling ./outer:./outer./outerendInnerenOuterQ 2 Why $_ isn't set when sourcing inner ?It seems that $_ is never set again when executing a script, I don't know if it is a normal or not. Anyway if it is not possible to use $_, is there an alternative secure way to get the last command executed inside a script ?
How to properly use $_ inside a tcsh script sourced from another tcsh script?
shell script;tcsh