1

In Bash, this work:

FOO=foo BAR=bar a_command

But how to make it works?

ENV="FOO=foo BAR=bar"
$ENV a_command

I got:

FOO=foo: command not found

2 Answers 2

3

See if this helps:

  sh -c "$ENV a_command"
Sign up to request clarification or add additional context in comments.

Comments

2

This is what the env command is for

env $ENV a_command

Note that the behaviour you see is documented in the manual -- the shell looks for variable assignments before expanding variables.

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.