Properly escape strings and expand env variables before running commands
from run_in_env.py