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.
Full bash script:
#!/bin/bash
DIR="$(cd `dirname $0` && pwd)"
eval $("${DIR}/test.py" "$2")
exit $?
Python script (not full script but give a good idea):
#!/usr/local/bin/python3
print('export var1="{0}"\nexport var2="{1}"\nexport var3="{2}"\nexport var4="{2}"'.format(string1, string2, string3))
bash-4.2$ ./x export SOME_VAR="hello world" export ANOTHER_VAR="hello" bash-4.2$ eval $(./x) bash-4.2$ echo $SOME_VAR hello world
. Note you shouldn't have the secondexport
in the output, but it won't stop the code working – Stephen Harris Nov 18 '18 at 18:39export
multiple variables. For me it doesn't stop the code from working but it also doesn't export any vars to the environment. I tried using both#!/bin/bash
and#!/bin/sh
i am on bash3.2 – masterpiece Nov 18 '18 at 18:47