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: Nicholas Chambers
Subject: Re: [Help-bash] Separation of compound commands
Date: Tue, 14 Mar 2017 11:42:16 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.0



On 3/14/17 11:24 AM, D630 wrote:
Why does A work, but B doesn't?

# A
{ { :; } }
if :; then if :; then :; fi fi
{ (:) }

Braces can be nested, however statements/commands need to be terminated. That is why the first works. I am not sure what part you don't understand in the second example. For the third, bash can tell that the statement : is over since it is wrapped in ()'s. If it didn't have those you would need a semicolon again (ie { :; }).


# B
{ (()) }
{ [[ 1 ]] }



(()) is a very different kind of statement than (:). (()) is for math. { (()); } works. { ( (()) ) } works. { (( 3 + 4 )); } works. Same with [[ 1 ]]. It is a statement, so it needs some kind of delimiter for bash to say its finished. Again, { ( [[ 1 ]] ) } works, and { [[ 1 ]]; } works.

--
Nicholas Chambers
Technical Support Specialist
address@hidden
1.800.444.9267
www.lightspeedsystems.com




reply via email to

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