Skip to content

Instantly share code, notes, and snippets.

@mattintosh4
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save mattintosh4/7fd4719488c03b290d3f to your computer and use it in GitHub Desktop.

Select an option

Save mattintosh4/7fd4719488c03b290d3f to your computer and use it in GitHub Desktop.
#!/bin/bash
bash -c 'declare -p VAR'
VAR=1 bash -c 'declare -p VAR'
bash -c 'declare -p VAR'
bash: line 0: declare: VAR: not found
declare -x VAR="1"
bash: line 0: declare: VAR: not found
$ CC=gcc CXX=g++ ./configure
$ set | grep ^LANG=
LANG=en_US.UTF-8
$ LANG=C set | grep ^LANG=
LANG=en_US.UTF-8
$ (LANG=C; set) | grep ^LANG=
LANG=C
$ LANG=C bash -c 'declare -p LANG'
declare -x LANG="C"
$ python -c 'import subprocess; subprocess.call(["LANG=C", "bash", "-c", "declare -p LANG"])'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
$ env LANG=C bash -c 'declare -p LANG'
declare -x LANG="C"
$ python -c 'import subprocess; subprocess.call(["env", "LANG=C", "bash", "-c", "declare -p LANG"])'
declare -x LANG="C"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment