0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.