Re: sh 'continue' shenanigans: negating

2024-02-15 Thread Vincent Lefevre via austin-group-l at The Open Group
On 2024-02-15 10:54:09 +0700, Robert Elz via austin-group-l at The Open Group wrote: > I suspect you're confusing exit status and the ? special param - they're > not the same thing. Every utility, and the shell compound commands, have > an exit status. What actually appears in ? is specified,

Re: sh 'continue' shenanigans: negating

2024-02-15 Thread Chet Ramey via austin-group-l at The Open Group
On 2/14/24 6:40 PM, Christoph Anton Mitterer wrote: On Wed, 2024-02-14 at 09:18 -0500, Chet Ramey via austin-group-l at The Open Group wrote: POSIX requires this, since it says that return sets $? to 1 here. I assume you mean the description of the exit status from `return`? No, I mean

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Robert Elz via austin-group-l at The Open Group
Date:Wed, 14 Feb 2024 20:15:59 -0800 (PST) From:"Roger Marquis via austin-group-l at The Open Group" Message-ID: <6sn184nr-6299-838p-qpro-03qs07401...@mx.roble.com> | Never seen a script use "!" in this way. Is it undocumented? No. That particular usage is

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Robert Elz via austin-group-l at The Open Group
Date:Thu, 15 Feb 2024 00:40:24 +0100 From:"Christoph Anton Mitterer via austin-group-l at The Open Group" Message-ID: <9e56d4028f077e0d5dcc2ec2448de62b400a69a3.ca...@scientia.org> | If so, then IMO strictly speaking, it doesn't say whose $? shall be set | that

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Oğuz via austin-group-l at The Open Group
On Thursday, February 15, 2024, Harald van Dijk via austin-group-l at The Open Group wrote: > > Because the eval command parses a command from a string, here, the second > ! is not part of the last pipeline. The last pipeline is just "break". The > "eval" command's exit status would be negated,

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Christoph Anton Mitterer via austin-group-l at The Open Group
On Wed, 2024-02-14 at 09:18 -0500, Chet Ramey via austin-group-l at The Open Group wrote: > POSIX requires this, since it says that return sets $? to 1 here. I assume you mean the description of the exit status from `return`? > The value of the special parameter '?' shall be set to n, an >

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Harald van Dijk via austin-group-l at The Open Group
On 13/02/2024 22:38, Harald van Dijk via austin-group-l at The Open Group wrote: On 13/02/2024 21:04, Thorsten Glaser via austin-group-l at The Open Group wrote: > After all, the continue utility doesn't know it's called by the ! construct. In ash-derived shells, this basically works because

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Chet Ramey via austin-group-l at The Open Group
On 2/14/24 12:06 AM, Oğuz wrote: On Tuesday, February 13, 2024, Chet Ramey via austin-group-l at The Open Group mailto:austin-group-l@opengroup.org>> wrote: `continue' is a builtin; continue has a return status; `!' says to negate it. It seems easy to come to the conclusion that the

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Oğuz via austin-group-l at The Open Group
On Wed, Feb 14, 2024 at 11:08 AM Harald van Dijk wrote: > I still see a difference between yash 2.53 and 2.54, not 2.54 and > 2.55 Must be an error on my part > but in dash, gwsh, and yash alike, it looks like it is that same > fix for the return command that also affected the break and

Re: sh 'continue' shenanigans: negating

2024-02-14 Thread Harald van Dijk via austin-group-l at The Open Group
On 14/02/2024 07:54, Oğuz wrote: On Wed, Feb 14, 2024 at 9:58 AM Harald van Dijk wrote: The test script with 'return'? I mean this one: for x in y; do ! continue done echo $? Ah, thanks for the clarification. I still do not see the same results as you (I still see a

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Oğuz via austin-group-l at The Open Group
On Wed, Feb 14, 2024 at 9:58 AM Harald van Dijk wrote: > The test script with 'return'? I mean this one: for x in y; do ! continue done echo $?

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Harald van Dijk via austin-group-l at The Open Group
On 14/02/2024 06:16, Oğuz wrote: On Wed, Feb 14, 2024 at 8:47 AM Harald van Dijk wrote: POSIX specifies: > The value of the special parameter '?' shall be set to n, an unsigned decimal integer, or to the exit status of the last command executed if n is not specified. In your example, n is

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Oğuz via austin-group-l at The Open Group
On Wed, Feb 14, 2024 at 8:47 AM Harald van Dijk wrote: > POSIX specifies: > > > The value of the special parameter '?' shall be set to n, an unsigned > decimal integer, or to the exit status of the last command executed if n > is not specified. > > In your example, n is 1, therefore $? shall be

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Harald van Dijk via austin-group-l at The Open Group
On 14/02/2024 05:06, Oğuz via austin-group-l at The Open Group wrote: On Tuesday, February 13, 2024, Chet Ramey via austin-group-l at The Open Group > wrote: `continue' is a builtin; continue has a return status; `!' says to negate it. It seems easy

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Oğuz via austin-group-l at The Open Group
On Tuesday, February 13, 2024, Chet Ramey via austin-group-l at The Open Group wrote: > > `continue' is a builtin; continue has a return status; `!' says to > negate it. It seems easy to come to the conclusion that the script > should return 1. > The same can be said about `return'. But bash

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Harald van Dijk via austin-group-l at The Open Group
On 13/02/2024 21:04, Thorsten Glaser via austin-group-l at The Open Group wrote: Chet Ramey wrote, according to the list archive ontinue' is a builtin; continue has a return status; !' says to negate it. It seems easy to come to the conclusion that the script should return 1. Yes, I can see

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Thorsten Glaser via austin-group-l at The Open Group
Chet Ramey wrote, according to the list archive (hasn’t arrived here yet, probably due to greylisting, so best don’t Cc me so the mailing list copy will arrive, or, if you must, Cc a different address of mine, which will then end up in my normal INBOX): >ontinue' is a builtin; continue has a

Re: sh 'continue' shenanigans: negating

2024-02-13 Thread Chet Ramey via austin-group-l at The Open Group
On 2/13/24 2:48 PM, Thorsten Glaser via austin-group-l at The Open Group wrote: Hi, I’ve got the following issue, and… yes I can see how the reporter could come to the conclusion that it should “return” 1, but… … at what point does “continue” “return”? Where do I stop operating?