help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Separation of compound commands


From: Chet Ramey
Subject: Re: [Help-bash] Separation of compound commands
Date: Tue, 14 Mar 2017 15:47:15 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 3/14/17 12:24 PM, D630 wrote:
> Why does A work, but B doesn't?
> 
> # A
> { { :; } }
> if :; then if :; then :; fi fi
> { (:) }
> 
> # B
> { (()) }
> { [[ 1 ]] }

The stuff between the braces has to be a compound_list. A compound_list
needs a terminator (`&', `;', `\n', etc.).  The (( and [[ commands aren't
specified as being terminated by operators in the bash grammar; they're
more like commands that begin and end with reserved words.  When you read
a reserved word like ]] or )), you are not in a position to read another
reserved word (`}' is a reserved word, not an operator), so you need a
separator, which in this case is the list terminator.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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