I have this command

$("${DIR}/test.py" "$1")

the output of which is

export SOME_VAR="hello world" export ANOTHER_VAR="hello"

But eval $("${DIR}/test.py" "$1")

seems to do nothing. What am I doing wrong?

I want to export those variables in my shell script.

  • did you mean that the output of ${DIR}/test.py" "$1" is "export..."? – niry Nov 18 '18 at 4:01
  • @niry yes the output is export ..... – masterpiece Nov 18 '18 at 9:03
  • then try without eval, or without $() – niry Nov 18 '18 at 14:48
  • neither would work. Without eval, i get the output i posted above. With $() I wont get command substitution and hence just get the same output i posted above. I want to "evaluate" that output too in my script. – masterpiece Nov 18 '18 at 18:15
  • Are you using bash? top line has #!/bin/bash? – niry Nov 18 '18 at 18:44

After discussion, we determined that the problem was not using source to allow exporting vars to the current shell.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.