Observed an interesting bash behavior that I don't understand.
Basically, when chaining commands in bash, whether there's a semi-colon between the two commands seem to make a difference in bash behavior. In particular the two examples below, one can read the env variable in Python, the other cannot
yuli@yuli-desktop:~$ A=1; python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['A']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/os.py", line 675, in __getitem__
raise KeyError(key) from None
KeyError: 'A'
>>> exit()
In a new bash process:
yuli@yuli-desktop:~$ A=1 python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>>
>>>
>>> os.environ['A']
'1'