I'm trying to get the current bash version from python using subprocess.
In my terminal, I can use printf "%s\n" $SHELL to get /bin/bash and printf "%s\n" $BASH_VERSION to get 5.1.8(1)-release.
So I prepared this python script:
>>> import subprocess
>>> subprocess.check_output(['printf "%s\n" $SHELL'], shell=True, stderr=subprocess.STDOUT)
b'/bin/bash\n'
>>> subprocess.check_output(['printf "%s\n" $BASH_VERSION'], shell=True, stderr=subprocess.STDOUT)
b'\n' <-- This output is wrong
Anyone could explain me why the output of printf $BASH_VERSION in subprocess differ from the terminal one?