In a script I'm debugging, I see it use $_ at the beginning of the file. It appears to suck in the full command that called the file. When trying to wrap this script in another script though, the $_ doesn't appear to suck in anything at all which causes the rest of the script to bomb.
I tried using $_ later in the script and it appears to take the previously executed command and either reruns it or just saves the output of the last command.
So if it is saving the results of the last saved command, why is it empty when another script calls into the script trying to use $_ at the beginning?
Maybe the real question is what is different about the environment between a script and the cmd line that would result in this different behavior, and what would be the WA or solution since the subscript I'm debugging isn't writable by me.
The below code also shows some weirdness in that if echo $_ is in the first line of a script, it pulls the previous cmd run on the cmd line, but if echo $_ is used again, it always outputs the cmd used to call the script.
echo $_ echo $_ echo $_
>echo "foo" foo >echo "bar" bar >source ./test echo "bar" source ./test source ./test