bug-bash
[Top][All Lists]
Advanced

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

Re: unset does not remove functions like a[b] unless -f is specified


From: Chet Ramey
Subject: Re: unset does not remove functions like a[b] unless -f is specified
Date: Fri, 3 Feb 2023 21:33:40 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.1

On 2/3/23 7:01 PM, Robert Elz wrote:
     Date:        Fri, 3 Feb 2023 11:22:23 -0500
     From:        Chet Ramey <chet.ramey@case.edu>
     Message-ID:  <f1e549d5-59b0-e0af-c02f-fc3c8e50fa70@case.edu>

   | > Hmm, I wonder whether <(:) could be a valid function name,
   | > if it expands to something like /dev/fd/63?
   |
   | Bash doesn't allow that; it treats the < like a $ in this case.

If unquoted, the '<' would be an operator (redirection operator)
(or with bash extensions, <( is probably the operator there - doesn't
matter here) - operators cannot be part of a word, that violates the
tokenisation rules.

It's not an operator. It's a word expansion, just like $(). It doesn't
delimit words, and it doesn't require quoting. It's not documented to
be one of the disallowed characters (character sequence in this case), and
probably should not be.


I'm not sure why bash prohibits quotes around function names, to allow
names containing operators, and white space, as well as the expansion
characters ($ ` * ? and [), and the quote characters themselves.

It's probably inherited from reserved words. The reasons have been lost
to time.

Is there something about the implementation which would fail if that
rule was removed?

Probably not.

--
``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/




reply via email to

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