[Top][All Lists]

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

Re: declare/typeset can't set array to variable name

From: Chet Ramey
Subject: Re: declare/typeset can't set array to variable name
Date: Fri, 5 Jan 2018 14:53:06 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 1/5/18 2:05 PM, Tim Burnham wrote:

> Why does the parser inconsistently detect the identifier `${var2}'? In
> the 3rd line of my example, Bash assigns the given expression into
> `${var3}' as intended.

The parser is consistent. It doesn't mark that word as a valid assignment
statement, either, which has implications for how it's expanded (for
example, it undergoes word splitting). That word doesn't contain any
metacharacters, so it's not a syntax error.  It just appears as an argument
to `declare', which knows how to deal with it.

``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/

reply via email to

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