"local" is a shell reserved word, isn't it?

Bernd Petrovitsch bernd at petrovitsch.priv.at
Mon Nov 22 21:12:03 UTC 2010


On Mon, 2010-11-22 at 12:26 -0500, Paul Smith wrote: 
> On Mon, 2010-11-22 at 09:27 +0100, Bernd Petrovitsch wrote:
> > On Son, 2010-11-21 at 18:39 -0500, Paul Smith wrote: 
> > > On Mon, 2010-11-22 at 00:25 +0100, Cristian Ionescu-Idbohrn wrote:
> > > > Different shells (ash, dash, bash) handle the above in an unexpected
> > > > way. I would have expected a consistent:
> > > > 
> > > > foo: line 7: syntax error: bad function name
> > > 
> > > "local" is not a reserved word in POSIX.  There is no "local" keyword or
> > > definition in the POSIX shell.
> > 
> > In theory, it's not in POSIX. In practice, it's a keyword in bash. And
> > that's in the world today probably more important and relevant.
> 
> I strongly disagree with your position here (there are still a LOT of
> systems out there that don't provide bash at all, and even more
> where /bin/sh is not bash, and to any portable environment THAT'S the
> most important and relevant fact).
> 
> But, either way it doesn't change my answer since the question was why
> different shells don't all treat "local" as a reserved word.

Because it isn't one in *all* shells. But it is one in at least shell
which is not that seldom used.
Of course one can use it in sh-scripts and point to POSIX - but then one
should think about the implications (and if it's not more useful and
less work to plain simply avoid keywords from at least somewhat widely
used shells - including ash, hush, msh, ksh, zsh, ...).

Bernd
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at



More information about the busybox mailing list