help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] break and continue inside subshells


From: Dan Douglas
Subject: Re: [Help-bash] break and continue inside subshells
Date: Thu, 18 Oct 2012 20:05:08 -0500
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

The subshell is still aware of its context (being that it's a fork with 
essentially a copy of the parent environment), it just is isolated from the 
parent process and can't affect its control flow, so a jump to the end of the 
subshell seems reasonable. Another example would be within a function, calling 
"return" within a subshell will have a similar effect. The subshell still has 
to know to allow a call to return in the current context. I don't see any 
mention of these things in POSIX but the behavior makes sense.

mksh just refuses to break and prints an error. If it's unspecified then 
that's also valid I suppose.

You might also notice some funny things with pipes. Try this with Bash shopt 
lastpipe, with/without set -m, and in ksh93.

for x in 1 2; do printf "$x" >&2 | { break; printf X; }; printf Y; done
-- 
Dan Douglas



reply via email to

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