help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] What are the regex spec for function names?


From: Dan Douglas
Subject: Re: [Help-bash] What are the regex spec for function names?
Date: Sat, 8 Dec 2018 09:42:59 -0600

There is probably no easy regex to match strings bash will tolerate as
a function name without error. The accepted names vary in several
contexts.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05

"The function is named fname; 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. An implementation may allow other characters in a
function name as an extension."

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235

So:

^[_[:alpha:]][_[:alnum:]]+$

is close enough for most purposes. There is no easy regex to filter
the set of special builtin names.



reply via email to

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