bug-bash
[Top][All Lists]
Advanced

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

Re: REGRESSION: shellshock patch rejects valid function names


From: Stephane Chazelas
Subject: Re: REGRESSION: shellshock patch rejects valid function names
Date: Mon, 29 Sep 2014 16:29:52 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

2014-09-29 09:04:00 -0600, Eric Blake:
[...]
> > "The function is named fname; the application shall ensure that it is a
> > name (see XBD Name) and that it is not the name of a special built-in 
> > utility."
> > 
> > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05
> 
> Note that this particular requirement is on "the application" (aka the
> shell script defining the function) and NOT on "the implementation" (aka
> bash as the shell that is tracking the function definition).  There are
> a number of places where there are requirements on a strictly conforming
> application, where if they violate that requirement, then they have
> subjected themselves to unspecified behavior, and that the shell can do
> whatever it deems makes the most sense.  In other words, I _don't_ read
> this sentence of POSIX as requiring that 'bash -o posix' must reject
> arbitrary function names, only that a shell script trying to conform to
> POSIX must not attempt to define a function with such a name.
> 
> I would expect something like "It shall be an error if fname is the name
> of a special built-in utility", as _that_ would be a hard requirement on
> bash, not just the application.  Maybe we have a bug in the POSIX spec
> for a missing requirement.

I agree the requirement is on the application, and I can't see
why POSIX should force a shell to reject a function whose name
doesn't contain a valid identifier.

() are used for (...), $(...), $((...)) and in "case", but
outside of that should be quoted, so I suppose any shell can do
whatever they want with them. ksh/bash/zsh already use it for
globs or arrays for instance.

The function keyword is also reserved with undefined behavior,
so one shell could very well do:


function with weird name 'blah = blah' [
  my function definition
]

Or:

'blah blah'() {
  my function
}

(like zsh does).

Or:

()'blah blah'={ my function }

Or:

functions[blah blah]='my function'
(as in zsh, and again unspecified behaviour by POSIX).

None of which are valid POSIX shell syntax, so POSIX shells can
do whatever they want with them.

-- 
Stephane




reply via email to

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