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: Koichi Murase
Subject: Re: unset does not remove functions like a[b] unless -f is specified
Date: Sat, 4 Feb 2023 22:45:54 +0900

2023年2月4日(土) 20:43 Oğuz İsmail Uysal <oguzismailuysal@gmail.com>:
> On 2/4/23 12:23 PM, Koichi Murase wrote:
> > Changing the behavior related to the function names wouldn't make the
> > behavior of the shell entirely unspecified
> I see, but that's not what you're suggesting. You're suggesting that how
> command search and execution works be changed to allow functions that
> contain slashes in their names to prevent command search, and shadow
> filesystem entries including those of standard utilities.

I think the shells that do not support defining such a function are
not affected, so do not need to change the search & execution model.
Even the shells that allow defining such functions do not need to
really change the behavior because it is just explicitly stated as
`unspecified'.

> The fact that bash and zsh already allow it doesn't mean it's a good
> idea.

I think the last sentence of my second last reply to you [1] would be
the reply to this sentence. I'm not trying to argue that it's a good
idea based on the existing implementations, Bash and Zsh. Even if we
would forget about the existing implementations, I'm not sure if it
would absolutely be a good idea to disallow calling functions with
slashes in their names.

[1] https://lists.gnu.org/archive/html/bug-bash/2023-02/msg00024.html

Anyway, the reason that I raised Bash and Zsh is for backward
compatibility. I haven't argued whether the behavior is
good/reasonable or not until you mentioned it, but I have been
discussing compatibility from the beginning. I first mentioned Zsh for
the compatibility with different shells that the POSIX seems to care
about.

> And it's easier to make the overall behavior unspecified than
> examine each shell and document this new behavior;

I thought we can just easily append a sentence to [2.9.1 / Command
Search and Execution / rule 2] like « When the implementation extends
the character set allowed in the function name to include a <slash> as
described in [2.9.5 Function Definition Command], if the command name
matches an already-defined function name, it is unspecified whether
rule 1c is applied or rule 2 is applied. »

It basically loosens the requirement by the standard so that the
behaviors of Bash and Zsh are included, so I don't think we need to
examine each shell for the new requirement.

But I might miss something non-trivial.

--
Koichi



reply via email to

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