A return that's run in a subshell doesn't cause the parent shell to
return.
**SNIP**
>> Are there many people actually using
>> "return" to exit a subshell? That would not really make code easy to
>> read.
> You misunderstood, or I was unclear.
*You* misunderstood, or I was
On Thu, Aug 19, 2010 at 11:12:03AM +0100, Marc Herbert wrote:
> > On Thu, 12 Aug 2010 08:16:21 -0400, Greg Wooledge
> >> A return that's run in a subshell doesn't cause the parent shell to
> >> return.
>
> Are there many people actually using
> "return" to exit a subshell? That would not really ma
> On Thu, 12 Aug 2010 08:16:21 -0400, Greg Wooledge
>> A return that's run in a subshell doesn't cause the parent shell to
>> return.
Granted but that does not mean it should behave like "exit", instead it
could simply error like this:
$ return
bash: return: can only `return' from a function or
On Thu, 12 Aug 2010 08:16:21 -0400, Greg Wooledge
wrote:
> You already know the reason it behaves the way it does, so I'm not
> quite sure what answer you expect to receive. It's not a bug -- it's
> the normal behavior of every shell.
>
> imadev:~$ sh -c 'f() { (return 0); return 1; }; f; echo
On Thu, Aug 12, 2010 at 01:23:20PM +1000, Martin Schwenke wrote:
> Description:
> I don't believe that the following behaviour is sensible or
> matches the standard/documentation:
>
> $ f () { { echo 1 ; echo 2 ; } | while read line ; do echo $line ;
> return 0 ; done ; echo f
Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba