I have some shell code I need to be debug, so I had the code dump its environment into a file
env > env.txt
and with my testing script I want to source it, test.sh:
. ./env.txt
echo $EXAMPLE
echo $EXAMPLE2
the contents of env.txt are:
EXAMPLE=sh /hello/command.sh
EXAMPLE2=/just/some/path
but, env does not put quotes around its values, which tends to cause a issue for $EXAMPLE, I get this error
test.sh: /hello/command.sh: not found
so clearly it is trying to run it instead of setting the variables.
what do you find is the quickest workaround for this problem?
Add the double quotes before redirecting the output to a file:
If you want to export the values to the environment, use the
-x
option todeclare
or use theexport
command instead.