I defined a shell script with a python script inside on the fly. Getting variables from shell to Python works fine, but the other way round does not work as expected. My Idea was to create an env variable os.environ["NEW_VAR"] = "test"
, but when trying is echo it, it is just None
.
#!/bin/bash
args=("$@")
GIT_PASSWORD=${args[0]}
export GIT_PASSWORD=$GIT_PASSWORD
python - << EOF
import os
print(os.environ.get("GIT_PASSWORD"))
os.environ["NEW_VAR"] = "test"
EOF
echo $GIT_PASSWORD
echo $NEW_VAR
echo "Back to bash"
- Why does that not work and 2. What is the correct way to pass a variable here? Thank you!