I'm trying to have the output of a python script be sourceable. i.e. I'd like to be able to run:
$ source <(python example.py)
It ALWAYS fails with the same issue:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
Here is example.py:
print("export ENV_VAR=abc")
Is there any way around this? I've attempted to try and catch the exception (BrokenPipeError) but it doesn't seem to work. The exception seems to prevent the sourcing from working since
$ echo $ENV_VAR
gives me nothing