help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Weird error of bash "/bin/sh: line 1: `BASH_FUNC_f%%': n


From: Bob Proulx
Subject: Re: [Help-bash] Weird error of bash "/bin/sh: line 1: `BASH_FUNC_f%%': not a valid identifier"
Date: Sat, 4 Oct 2014 12:53:38 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Peng Yu wrote:
> Eric Blake wrote:
> >> /tmp$ export -f f
> >
> > This line injects BASH_FUNC_f%% into the environment.
> 
> How to refer to BASH_FUNC_f%% if I want to?

Refer to it as "f".

> /tmp$ function f {
> > :
> > }
> 
> /tmp$  BASH_FUNC_f%%
> bash: BASH_FUNC_f%%: command not found

Don't try to access BASH_FUNC_f%% as that is an bash namedspaced
variable for function export.  If you want to refer to f as a function
then call the function.  Also better if you use the portable function
syntax and avoid using "function".

  $ fcn() { echo hello from function fcn ;}
  $ fcn
  hello from function fcn

If you export the function then that will create the special
namespaced variable.

  $ export -f fcn
  $ env | grep fcn
  BASH_FUNC_fcn%%=() {  echo hello from function fcn

But don't try to access it by the raw variable name.

> /tmp$ cat /tmp/main.sh
> #!/bin/sh

The /bin/sh is having trouble ignoring the variable name.  It should
do so silently.

> >> /bin/sh: line 1: `BASH_FUNC_f%%': not a valid identifier
> >
> > Your /bin/sh is buggy.  POSIX says that implementations should tolerate
> > (that is, silently ignore or erase) invalid environment variable names
> > that they do not understand, rather than loudly complain.  Since Mac OS
> > is proprietary, I cannot help you fix your /bin/sh; but please raise a
> > bug report to Apple to fix their /bin/sh.
> 
> But /bin/sh is essentially an earlier version of bash. Is there a
> problem with this version of bash?
> 
> /tmp$ /bin/sh --version
> GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)
> Copyright (C) 2007 Free Software Foundation, Inc.

As Eric has said /bin/sh should silently ignore those variables.
Doesn't matter if that is bash or other.  However you are running the
Apple patched version of bash.  So nothing we can do about it here.
File a bug with your vendor.

I will note that I checked an old version 3.2.51 and did not have an
invalid identifier problem.  It worked for me with the official
patches.  Therefore I conclude that Apple has added different patches
for their 3.2.51.  There were many other patches discussed around the
time of the security disclosure.

As you may have heard there has been a significant set of security
updates to bash in recent weeks.  Apple should have released updates
to bash along with everyone else for this.  Check to see if you are up
to date.  If so then open a bug with Apple that they need to release
patches for the recent problems.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]