Reputation: 167
I would like to do bash -c '<some smart bash script>'
that would output the actual string passed to -c.
In other words, if SCRIPT
is set to that smart script, bash -c "$SCRIPT"
should yield what's in $SCRIPT
.
Is that possible? If yes, how?
Thanks
Upvotes: 1
Views: 338
Reputation: 74078
See man bash
5.2 Bash Variables
...
BASH_EXECUTION_STRING
The command argument to the -c invocation option.
If you try
bash -c 'echo $BASH_EXECUTION_STRING'
it will give you
echo $BASH_EXECUTION_STRING
Upvotes: 5