I got a script using foo++() as function name, and at first I was
confused of a different behavior between bash 4.2, 4.4 and 5.0. After
crawling some mailing lists whether this is allowed at all, I found
this post:
Obviously the behavior regarding such a constructed name in 4.2 and
4.4 was not always coherent. And a plus sign is one of the additional
characters which Bash allows as an extension.
Nevertheless, also the version 5.0 has in its man-page the passage:
a)
name A word consisting only of alphanumeric characters and
underscores, and beginning with an alphabetic character or
an underscore. Also referred to as an identifier.
b)
name () compound-command [redirection]
function name [()] compound-command [redirection]
Shouldn't this be extended in the man-page to list all valid
characters? I even wonder where the original poster got the list from.
Hence there is a rule: if special characters are used inside a
function name, the the option -f must be used.
Maybe this is related to the fact, that `unset` works for both:
variables and (and afterwards) for left functions with this name.
Would it be sensible to jump inside `unset` to scan for a function
name, once an illegal name for a variable was found? – Or make the use
of "-f" always mandatory for functions?