[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] What is the regex for bash variable names?
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] What is the regex for bash variable names? |
Date: |
Wed, 7 Feb 2018 14:49:08 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 2/7/18 12:47 PM, Greg Wooledge wrote:
> On Wed, Feb 07, 2018 at 11:01:33AM -0600, Peng Yu wrote:
>> 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 address@hidden http://tiswww.cwru.edu/~chet/