bug-bash
[Top][All Lists]
Advanced

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

Re: question about exit command


From: Greg Wooledge
Subject: Re: question about exit command
Date: Wed, 19 Jan 2011 08:37:30 -0500
User-agent: Mutt/1.4.2.3i

On Wed, Jan 19, 2011 at 10:49:47AM +0000, Davide Brini wrote:
> In your second script, the "exit 0" part runs in a subshell, so "exit" exits 
> that subshell (and I'm somewhat surprised that no semicolon is required after 
> the closing bracket, but I may have missed something in the grammar).

He had parentheses (like this) not brackets.  You don't need semicolons
to terminate commands inside parentheses.  You *do* need them to terminate
commands inside curly braces.

(cd /foo && make)                               # subshell
foo || { echo "failure" >&2; exit 1; }          # command grouping

Note that you also don't need a space between the opening ( and the
command, whereas you do need a space between { and the command.  Otherwise,
the parser would treat {echo as a single word:

$ {echo failure}
bash: {echo: command not found

This is because ( is a metacharacter, but { is not.



reply via email to

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