Discussion:
[Help-bash] What is the regex for bash variable names?
Peng Yu
2018-02-07 17:01:33 UTC
Permalink
Hi, I'd like to know the exact definition of a bash variable name in
terms of regex. Is this documented somewhere? Thanks.
--
Regards,
Peng
Greg Wooledge
2018-02-07 17:47:09 UTC
Permalink
Post by Peng Yu
Hi, I'd like to know the exact definition of a bash variable name in
terms of regex. Is this documented somewhere? Thanks.
name A word consisting only of alphanumeric characters and under‐
scores, and beginning with an alphabetic character or an under‐
score. Also referred to as an identifier.
Chet Ramey
2018-02-07 19:49:08 UTC
Permalink
Post by Greg Wooledge
Post by Peng Yu
Hi, I'd like to know the exact definition of a bash variable name in
terms of regex. Is this documented somewhere? Thanks.
name A word consisting only of alphanumeric characters and under‐
scores, and beginning with an alphabetic character or an under‐
score. Also referred to as an identifier.
Technically, you have to add "from the portable character set" like Posix
does. Bash doesn't allow variable names that contain non-ASCII characters
that might be alphabetics in the current locale.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Loading...