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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.