bug-bash
[Top][All Lists]
Advanced

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

Re: Document what's allowed in function names


From: Chet Ramey
Subject: Re: Document what's allowed in function names
Date: Wed, 25 May 2011 14:36:39 -0400

> 2011-05-24 17:23:20 -0400, Chet Ramey:
> [...]
> > > Why would you put any restriction on the allowed name of a function?
> [...]
> > Because Posix does, and because unset without -f has to enforce the variable
> > name restrictions.  (Though the language has been relaxed in the latest
> > standard.)
> [...]
> 
> POSIX puts restrictions on the name of functions used by
> applications, but I can't see anywhere it restricting what the
> shell allows.

The `application shall ensure ...' language was added long after the first
version of the standard was released.  The original version from 1992
required that a function name be a `name' as the grammar defined it.
I don't know whether that was changed in the 2001 version of the standard,
but it was different by 2004, at least.

> Note that all of pdksh, mksh, zsh (at least) allow
> foo+bar() { w; } for instance
> ksh93 allows foo.get() { w; }

Bash allows all of these forms, as well as things like `!!', by default.
It continues to enforce the original Posix restrictions in Posix mode.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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