Reputation: 38
I have an inclusion file test.inc:
export XXX=xxx
I use it when call bash to interpret a string:
bash -c ". test.inc; echo $XXX"
But the variable is not set at the point of echo command. If I do 'export' I can see it though:
bash -c ". test.inc; export"
Shows
declare -x XXX="XXX"
How do I make my first command see the exported variables from sourced files when I use bash -c syntax?
Upvotes: 0
Views: 71
Reputation: 189679
You are using double quotes. Therefore your current shell expands $XXX
long before the bash -c
instance sees it. Switch to single quotes, or escape the dollar sign.
Upvotes: 1