Re: [Help-bash] What are the regex spec for function names?
From:
Peng Yu
Subject:
Re: [Help-bash] What are the regex spec for function names?
Date:
Sun, 6 Jan 2019 19:50:53 -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.
Could anybody help explain How this is done at the parsing?
I am still learning the code. It seems that bash does not rely on flex
to tokenize. But how to recognize function that can not be expressed
in regex?
--
Regards,
Peng
[Prev in Thread]
Current Thread
[Next in Thread]
Re: [Help-bash] What are the regex spec for function names?,
Peng Yu<=