On Oct 15, 2014, at 9:38 AM, lorenz.bucher....@rohde-schwarz.com wrote:

> Hello,
> in refer to 
> http://lists.gnu.org/archive/html/bug-bash/2014-09/msg00278.html variables 
> with suffix "%%" can't be set/exported.
> This makes problems restoring environments which where saved by external 
> programs like printenv (see example below)
> 
> I saw this issue on Ubuntu 12.04 with
> bash version GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
> 
> examples:
> 
> $ foo() { echo "bar"; }
> $ export -f foo
> $ echo "export BASH_FUNC_foo%%='$(printenv BASH_FUNC_foo%%)'" | tee ./env
> export BASH_FUNC_foo%%='() {  echo "bar"
> }'
> $ source ./env
> bash: export: `BASH_FUNC_foo%%=() {  echo "bar"
> }': not a valid identifier
> 
> 
> $ export BASH_FUNC_foo%%='() {  echo "bar"; }'
> bash: export: `BASH_FUNC_foo%%=() {  echo "bar"; }': not a valid 
> identifier

Given the changes made for shellshock, I doubt the above will ever work again. 
Try

   env | sed 's/^BASH_FUNC_\([^%]*\)%%=/\1/'

or

   echo "export BASH_FUNC_foo%%='$(printenv BASH_FUNC_foo%%)'" | sed 
's/^BASH_FUNC_\([^%]*\)%%=/\1/' | tee ./env

to strip function descriptors.


Reply via email to