[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dashes in function names: Undocumented?
From: |
Chet Ramey |
Subject: |
Re: Dashes in function names: Undocumented? |
Date: |
Thu, 13 Aug 2020 10:02:22 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 8/13/20 3:32 AM, Robert Elz wrote:
> Date: Wed, 12 Aug 2020 11:05:40 -0400
> From: Eli Schwartz <eschwartz@archlinux.org>
> Message-ID: <f53f8a84-ac66-6d61-7066-01c14e8f2ce4@archlinux.org>
>
>
> | When in posix mode, fname must be a valid shell name and may not be the
> | name of one of the POSIX special builtins. In default mode, a function
> | name can be any unquoted shell word that does not contain $.
>
> There's no need for the posix mode test here, in posix mode a function
> with the same name as a special builtin won't be found (the special builtin
> is located first) but it doesn't need to be an error to define it (posix
> does not require that).
It's an application restriction that bash chooses to enforce: "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."
It's a non-fatal error; some shells, like dash and ksh93, make it a fatal
syntax error to define a function with the same name as a special builtin.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/