I want to run a series of bash commands generated by a Python script. The commands are of the form export foo="bar" and alias foo=bar. They must modify the environment of the current process.
This works great:
$(./generate_commands.py)
until an export command contains a space e.g. export x="a b". This generates an error, and only "a is exported (quotes included).
Currently I'm working around this by outputting generate_commands to a temporary file and sourcing that, but is there a more elegant solution?
python, then, regardless of the exact syntax or method of doing so, runningbashin order to evaluate the commands you generated will start a separate process, which by definition cannot influence the environment variables of its parent process.