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: Greg Wooledge
Subject: Re: unset does not remove functions like a[b] unless -f is specified
Date: Thu, 2 Feb 2023 15:36:30 -0500

On Thu, Feb 02, 2023 at 03:02:41PM -0500, Dale R. Worley wrote:
> Greg Wooledge <greg@wooledge.org> writes:
> > I'd be totally OK with restricting the function namespace a bit more.
> > Function names should not be allowed to contain backticks or less-than
> > or greater-than signs (in my opinion).  I'm still undecided about
> > parentheses, but I'm leaning toward "denied".
> 
> I'd be perfectly fine if function names had to be "names", and my memory
> is that old versions of Bash enforced that.  But the manual page hints
> that was changed, and probably for a reason.  So proceed with caution.
> 
>               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 a legitimate reason to support function names that contain *some*
punctuation characters beyond underscore.  Hyphens, periods, colons (single
or double) -- all fine.  Some people like namespace::function names, and
bash should continue to allow those.

A case might be made that slashes should also be disallowed, because it
allows exported function names like /bin/echo to be inherited by a
script, potentially causing all kinds of odd behavior.  But that's a
different battle.



reply via email to

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