[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in function return statement in while subshell
From: |
Pierre Gaston |
Subject: |
Re: Bug in function return statement in while subshell |
Date: |
Tue, 30 Jul 2013 12:11:07 +0300 |
On Mon, Jul 29, 2013 at 8:15 PM, Roman Rakus <rrakus@redhat.com> wrote:
> On 07/29/2013 05:06 PM, Chet Ramey wrote:
>>
>> On 7/29/13 10:55 AM, Roman Rakus wrote:
>>>
>>> I didn't take a look on where the problem could be, but it is discussed
>>> on
>>> stackoverflow [1].
>>>
>>> Looks like return builtin falsely exit execution of while loop instead of
>>> function.
>>
>>
>> What would you like to see happen? You're in a subshell: the function
>> can't return, since this is not the shell that called it. Do you want
>> parent and child shells both continuing execution after the function call?
>>
>> Chet
>>
> As Chris said, some error, because return is not in function.
>
> Example:
> f1() {
> : | while :; do return 3; done
> echo $?
> return 1
> }
> echo $?
> f1; echo $?
> return 2
>
> Looks like the bash doesn't restore the i'm-in-function indicator when
> running compound command (like while or if) in functions' subshell.
>
> RR
>
what about things like this: foo () ( return 1; )
I suspect it's not so uncommon, it's in a subshell, in a function?
- Bug in function return statement in while subshell, Roman Rakus, 2013/07/29
- Re: Bug in function return statement in while subshell, Roman Rakus, 2013/07/29
- Re: Bug in function return statement in while subshell,
Pierre Gaston <=
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
- Re: Bug in function return statement in while subshell, Pierre Gaston, 2013/07/30
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
- Re: Bug in function return statement in while subshell, Pierre Gaston, 2013/07/30
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30
- Re: Bug in function return statement in while subshell, Greg Wooledge, 2013/07/30
- Re: Bug in function return statement in while subshell, Chet Ramey, 2013/07/30
- Re: Bug in function return statement in while subshell, Roman Rakus, 2013/07/30
- Re: Bug in function return statement in while subshell, Greg Wooledge, 2013/07/30
- Re: Bug in function return statement in while subshell, Chris Down, 2013/07/30