Re: return from function doesn't work when used in tail of pipeline

2010-08-19 Thread Marc Herbert
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

Re: return from function doesn't work when used in tail of pipeline

2010-08-19 Thread Greg Wooledge
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

Re: return from function doesn't work when used in tail of pipeline

2010-08-19 Thread Marc Herbert
> 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

Re: return from function doesn't work when used in tail of pipeline

2010-08-12 Thread Martin Schwenke
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

Re: return from function doesn't work when used in tail of pipeline

2010-08-12 Thread Greg Wooledge
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