Bash Version: 3.2
Patch Level: 33
Release Status: release
Description:
~$ env -i '1=a' sh -c 'export -p'
export 1="a"
export OLDPWD
export PWD="/home/chazelas"
export SHLVL="1"
~$ env -i '1=a' bash -c 'export -p'
declare -x 1="a"
declare -x OLDPWD
declare -x PWD="/home/chazelas"
declare -x SHLVL="1"
~$ env -i '1=a' sh -c 'export -p' | sh
sh: line 1: export: `1=a': not a valid identifier
~$ env -i '1=a' bash -c 'export -p' | bash
bash: line 1: declare: `1=a': not a valid identifier
ash/dash are also affected. zsh, pdksh, mksh, posh, ksh93 are not.
Repeat-By:
see above.
Fix:
only report about shell variables.
> Bash Version: 3.2
> Patch Level: 33
> Release Status: release
>
> Description:
> ~$ env -i '1=a' sh -c 'export -p'
> export 1="a"
> export OLDPWD
> export PWD="/home/chazelas"
> export SHLVL="1"
> ~$ env -i '1=a' bash -c 'export -p'
> declare -x 1="a"
> declare -x OLDPWD
> declare -x PWD="/home/chazelas"
> declare -x SHLVL="1"
> ~$ env -i '1=a' sh -c 'export -p' | sh
> sh: line 1: export: `1=a': not a valid identifier
> ~$ env -i '1=a' bash -c 'export -p' | bash
> bash: line 1: declare: `1=a': not a valid identifier
Thanks for the report. The right fix is to ignore words in the
environment that are not valid shell assignment statements. Bash
already does this for words without an `=', for instance.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU ch...@case.edu http://cnswww.cns.cwru.edu/~chet/