When I run the /bin/bash process with 2 parameters -c and SomeUserInput,
where SomeUserInput is echo $TERM
The output is
xterm-256color
Is there a way I can set the value of $TERM via a command line parameter to /bin/bash so the above invokation of echo $TERM would print something else that I specify?
(Yes, I’ve done a lot of digging in man bash and searching elsewhere, but couldn’t find the answer; although I think it’s likely there.)
First of all, since you used double quotes, that prints the value of TERM in your current shell, not the bash you invoke. To do that, use
/bin/bash -c 'echo $TERM'.To set the value of TERM, you can
export TERM=linuxbefore running that command, set it only for that shell with eitherTERM=linux /bin/bash -c 'echo $TERM'(shell expression), or/usr/bin/env TERM=linux /bin/bash -c 'echo $TERM'(execve compatible (as for find -exec)).Update:
As for your edit of only using command line parameters to
/bin/bash, you can do that without modifying your input like this: