Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I surely do hope that's a syntax error. -- Larry Wall in <199710011752.KAA21624@wall.org>


devel / comp.unix.shell / Re: Don't need no stinkin' URLs

SubjectAuthor
* About the exit status of the `if' command.hongy...@gmail.com
`* Re: About the exit status of the `if' command.Janis Papanagnou
 `* Re: About the exit status of the `if' command.hongy...@gmail.com
  `* Re: About the exit status of the `if' command.Janis Papanagnou
   `* Re: About the exit status of the `if' command.hongy...@gmail.com
    +* Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)Kenny McCormack
    |+* Re: Don't need no stinkin' URLs (Was: About the exit status of theJanis Papanagnou
    ||`* Re: Don't need no stinkin' URLs (Was: About the exit status of theKenny McCormack
    || +- Re: Don't need no stinkin' URLs (Was: About the exit status of theJanis Papanagnou
    || `* Re: Don't need no stinkin' URLsWilliam Ahern
    ||  `- Re: Don't need no stinkin' URLsAxel Reichert
    |`- Re: Don't need no stinkin' URLs (Was: About the exit status of thehongy...@gmail.com
    +* Re: About the exit status of the `if' command.Janis Papanagnou
    |`* POSIX links (was Re: About the exit status of the `if' command.)Janis Papanagnou
    | `- Re: POSIX links (was Re: About the exit status of the `if' command.)hongy...@gmail.com
    `* Re: About the exit status of the `if' command.Helmut Waitzmann
     `- Re: About the exit status of the `if' command.hongy...@gmail.com

1
About the exit status of the `if' command.

<acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4864&group=comp.unix.shell#4864

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:624:: with SMTP id a4mr3071962qvx.127.1642767220053;
Fri, 21 Jan 2022 04:13:40 -0800 (PST)
X-Received: by 2002:a05:6214:ca7:: with SMTP id s7mr3145882qvs.16.1642767219880;
Fri, 21 Jan 2022 04:13:39 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 21 Jan 2022 04:13:39 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
Subject: About the exit status of the `if' command.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 21 Jan 2022 12:13:40 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: hongy...@gmail.com - Fri, 21 Jan 2022 12:13 UTC

See the following testing:

$ ( if [ 1 -eq 2 ]; then echo ok; fi ); echo $?
0

$ [ 1 -eq 2 ]; echo $?
1

$ help if
[...]
Exit Status:
Returns the status of the last command executed.

So, I think in the first test, the exit status should be the "[ 1 -eq 2 ]", but as you can see, this is not the case. Where is my understanding wrong?

Regards,
HZ

Re: About the exit status of the `if' command.

<sse8nh$ukr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4865&group=comp.unix.shell#4865

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: About the exit status of the `if' command.
Date: Fri, 21 Jan 2022 13:25:21 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <sse8nh$ukr$1@dont-email.me>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jan 2022 12:25:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="81f2c5b36b78674faa7eb3594f8b717f";
logging-data="31387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZHzR4CGKfYAieDe6P4h7W"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:FfrMAT2xijRVytQ0lGB71I6Rthk=
In-Reply-To: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
 by: Janis Papanagnou - Fri, 21 Jan 2022 12:25 UTC

On 21.01.2022 13:13, hongy...@gmail.com wrote:
> See the following testing:
>
> $ ( if [ 1 -eq 2 ]; then echo ok; fi ); echo $? 0
>
> $ [ 1 -eq 2 ]; echo $? 1
>
> $ help if [...] Exit Status: Returns the status of the last command
> executed.
>
>
> So, I think in the first test, the exit status should be the "[ 1 -eq
> 2 ]", but as you can see, this is not the case. Where is my
> understanding wrong?

You missed that no command has been executed. The 'if' compound
command would have executed the else case, but there isn't one.
Thus 0 is returned.

Janis

>
> Regards, HZ
>

Re: About the exit status of the `if' command.

<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4866&group=comp.unix.shell#4866

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:6288:: with SMTP id w130mr2540173qkb.691.1642769990702; Fri, 21 Jan 2022 04:59:50 -0800 (PST)
X-Received: by 2002:a37:94c1:: with SMTP id w184mr2571424qkd.264.1642769990539; Fri, 21 Jan 2022 04:59:50 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 21 Jan 2022 04:59:50 -0800 (PST)
In-Reply-To: <sse8nh$ukr$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com> <sse8nh$ukr$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
Subject: Re: About the exit status of the `if' command.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 21 Jan 2022 12:59:50 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 25
 by: hongy...@gmail.com - Fri, 21 Jan 2022 12:59 UTC

On Friday, January 21, 2022 at 8:25:26 PM UTC+8, Janis Papanagnou wrote:
> On 21.01.2022 13:13, hongy...@gmail.com wrote:
> > See the following testing:
> >
> > $ ( if [ 1 -eq 2 ]; then echo ok; fi ); echo $? 0
> >
> > $ [ 1 -eq 2 ]; echo $? 1
> >
> > $ help if [...] Exit Status: Returns the status of the last command
> > executed.
> >
> >
> > So, I think in the first test, the exit status should be the "[ 1 -eq
> > 2 ]", but as you can see, this is not the case. Where is my
> > understanding wrong?
> You missed that no command has been executed. The 'if' compound
> command would have executed the else case, but there isn't one.
> Thus 0 is returned.

Based on your above comments, I further noted the following description in help:

The exit status of the entire construct is the exit status of the last
command executed, or zero if no condition tested true.

So, I obtained the following explanation: Given that the only condition "[ 1 -eq 2 ]" is false, we can say "no condition tested true" and therefore return zero.

Re: About the exit status of the `if' command.

<ssebh5$iji$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4867&group=comp.unix.shell#4867

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: About the exit status of the `if' command.
Date: Fri, 21 Jan 2022 14:13:09 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <ssebh5$iji$1@dont-email.me>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me>
<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jan 2022 13:13:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="81f2c5b36b78674faa7eb3594f8b717f";
logging-data="19058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1zjv3rw9t8n3Qe2jkueUb"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Dw6oXMUTFbgvfzvXJRPPL7SaU5g=
In-Reply-To: <4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 21 Jan 2022 13:13 UTC

On 21.01.2022 13:59, hongy...@gmail.com wrote:
> On Friday, January 21, 2022 at 8:25:26 PM UTC+8, Janis Papanagnou wrote:
>> On 21.01.2022 13:13, hongy...@gmail.com wrote:
>>> See the following testing:
>>>
>>> $ ( if [ 1 -eq 2 ]; then echo ok; fi ); echo $? 0
>>>
>>> $ [ 1 -eq 2 ]; echo $? 1
>>>
>>> $ help if [...] Exit Status: Returns the status of the last command
>>> executed.
>>>
>>>
>>> So, I think in the first test, the exit status should be the "[ 1 -eq
>>> 2 ]", but as you can see, this is not the case. Where is my
>>> understanding wrong?
>> You missed that no command has been executed. The 'if' compound
>> command would have executed the else case, but there isn't one.
>> Thus 0 is returned.
>
> Based on your above comments, I further noted the following description in help:
>
> The exit status of the entire construct is the exit status of the last
> command executed, or zero if no condition tested true.
>
> So, I obtained the following explanation: Given that the only
> condition "[ 1 -eq 2 ]" is false, we can say "no condition tested true"
> and therefore return zero.

I'm not sure why you formulate it that way. In case of

$ if [ 1 -eq 2 ]; then echo ok; else false ; fi ); echo $?
1

there's also "no condition tested true" and you don't get exit code 0.
The point is another one. It's probably the best to simply look up the
POSIX specs where it's clearly described:

"Exit Status
The exit status of the if command shall be the exit status of the then
or else compound-list that was executed, or zero, if none was executed."

It's clear, simple, and leaves no doubts, I hope.

Janis

Re: About the exit status of the `if' command.

<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4868&group=comp.unix.shell#4868

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:4109:: with SMTP id kc9mr3662732qvb.59.1642774504031;
Fri, 21 Jan 2022 06:15:04 -0800 (PST)
X-Received: by 2002:a37:4250:: with SMTP id p77mr2880783qka.430.1642774503841;
Fri, 21 Jan 2022 06:15:03 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 21 Jan 2022 06:15:03 -0800 (PST)
In-Reply-To: <ssebh5$iji$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me> <4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
Subject: Re: About the exit status of the `if' command.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 21 Jan 2022 14:15:04 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 55
X-Received-Bytes: 3453
 by: hongy...@gmail.com - Fri, 21 Jan 2022 14:15 UTC

On Friday, January 21, 2022 at 9:13:15 PM UTC+8, Janis Papanagnou wrote:
> On 21.01.2022 13:59, hongy...@gmail.com wrote:
> > On Friday, January 21, 2022 at 8:25:26 PM UTC+8, Janis Papanagnou wrote:
> >> On 21.01.2022 13:13, hongy...@gmail.com wrote:
> >>> See the following testing:
> >>>
> >>> $ ( if [ 1 -eq 2 ]; then echo ok; fi ); echo $? 0
> >>>
> >>> $ [ 1 -eq 2 ]; echo $? 1
> >>>
> >>> $ help if [...] Exit Status: Returns the status of the last command
> >>> executed.
> >>>
> >>>
> >>> So, I think in the first test, the exit status should be the "[ 1 -eq
> >>> 2 ]", but as you can see, this is not the case. Where is my
> >>> understanding wrong?
> >> You missed that no command has been executed. The 'if' compound
> >> command would have executed the else case, but there isn't one.
> >> Thus 0 is returned.
> >
> > Based on your above comments, I further noted the following description in help:
> >
> > The exit status of the entire construct is the exit status of the last
> > command executed, or zero if no condition tested true.
> >
> > So, I obtained the following explanation: Given that the only
> > condition "[ 1 -eq 2 ]" is false, we can say "no condition tested true"
> > and therefore return zero.
> I'm not sure why you formulate it that way. In case of
>
> $ if [ 1 -eq 2 ]; then echo ok; else false ; fi ); echo $?
> 1

This is equivalent to:

$ ( if [ 1 -eq 2 ]; then echo ok; else exit 1 ; fi ); echo $?
1
> there's also "no condition tested true" and you don't get exit code 0.
> The point is another one. It's probably the best to simply look up the
> POSIX specs where it's clearly described:

BTW, what's the URL where you find the following explanation?
> "Exit Status
> The exit status of the if command shall be the exit status of the then
> or else compound-list that was executed, or zero, if none was executed."

So, if I want to obtain a valid exit status, it must be explicitly set by the then or else compound-list.
> It's clear, simple, and leaves no doubts, I hope.

Got it. Thank you again.
> Janis

Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)

<ssegve$3eps9$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4869&group=comp.unix.shell#4869

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)
Date: Fri, 21 Jan 2022 14:46:06 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ssegve$3eps9$1@news.xmission.com>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com> <4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com> <ssebh5$iji$1@dont-email.me> <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
Injection-Date: Fri, 21 Jan 2022 14:46:06 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3630985"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 21 Jan 2022 14:46 UTC

In article <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>,
hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
....
>BTW, what's the URL where you find the following explanation?
>
>> "Exit Status
>> The exit status of the if command shall be the exit status of the then
>> or else compound-list that was executed, or zero, if none was executed."

Do "man bash", then search for: if
(that's literally 5 spaces then i then f)

And you'll get the 411.

BTW, the above text does not appear literally in my "man bash" as written;
I'm guessing that Janis got it from some other source. But the general
content is the same.

--
1) The only professionals who refer to their customers as "users" are
computer guys and drug dealers.
2) The only professionals who refer to their customers as "clients" are
lawyers and prostitutes.

Re: About the exit status of the `if' command.

<ssejb9$ekt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4870&group=comp.unix.shell#4870

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: About the exit status of the `if' command.
Date: Fri, 21 Jan 2022 16:26:33 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <ssejb9$ekt$1@dont-email.me>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me>
<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jan 2022 15:26:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="81f2c5b36b78674faa7eb3594f8b717f";
logging-data="15005"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/catOZiapMuvOn0fs1bRg2"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:SgLvbuVeZ9NKtsxE4AAlxgISV5k=
In-Reply-To: <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
 by: Janis Papanagnou - Fri, 21 Jan 2022 15:26 UTC

On 21.01.2022 15:15, hongy...@gmail.com wrote:
> On Friday, January 21, 2022 at 9:13:15 PM UTC+8, Janis Papanagnou wrote:
>
>> there's also "no condition tested true" and you don't get exit code 0.
>> The point is another one. It's probably the best to simply look up the
>> POSIX specs where it's clearly described:
>
> BTW, what's the URL where you find the following explanation?

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04

>
>> "Exit Status
>> The exit status of the if command shall be the exit status of the then
>> or else compound-list that was executed, or zero, if none was executed."

Janis

Re: Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)

<ssejua$jno$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4871&group=comp.unix.shell#4871

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Don't need no stinkin' URLs (Was: About the exit status of the
`if' command.)
Date: Fri, 21 Jan 2022 16:36:42 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <ssejua$jno$1@dont-email.me>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
<ssegve$3eps9$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jan 2022 15:36:42 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="81f2c5b36b78674faa7eb3594f8b717f";
logging-data="20216"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19upvz/uQIk3xwHBSGBW9tS"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:WgmMxmXhrtCGSAYPA+MkUO1HfhY=
In-Reply-To: <ssegve$3eps9$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 21 Jan 2022 15:36 UTC

On 21.01.2022 15:46, Kenny McCormack wrote:
> In article <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>,
> hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
> ...
>> BTW, what's the URL where you find the following explanation?
>>
>>> "Exit Status
>>> The exit status of the if command shall be the exit status of the then
>>> or else compound-list that was executed, or zero, if none was executed."
>
> Do "man bash", then search for: if
> (that's literally 5 spaces then i then f)
>
> And you'll get the 411.
>
> BTW, the above text does not appear literally in my "man bash" as written;
> I'm guessing that Janis got it from some other source.

My text was from the POSIX specs. (I've said that in my post but you
may have missed it.)

For basic standard stuff the POSIX specs are often better. The man
pages may differ (even for basic standard stuff) between shells.

> But the general content is the same.

Janis

Re: Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)

<ssemko$3ev4b$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4872&group=comp.unix.shell#4872

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Don't need no stinkin' URLs (Was: About the exit status of the
`if' command.)
Date: Fri, 21 Jan 2022 16:22:48 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ssemko$3ev4b$1@news.xmission.com>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com> <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com> <ssegve$3eps9$1@news.xmission.com> <ssejua$jno$1@dont-email.me>
Injection-Date: Fri, 21 Jan 2022 16:22:48 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3636363"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 21 Jan 2022 16:22 UTC

In article <ssejua$jno$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
....
>For basic standard stuff the POSIX specs are often better. The man
>pages may differ (even for basic standard stuff) between shells.

I would argue that the man page for one's specific shell is a better
reference than the abstract POSIX specs. The POSIX specs tell you what
*should* happen, while the man page will tell what *WILL* happen. The
later is, in the real world, of much greater importance.

Particularly for someone as literal-minded and "I just want it to work"
focused as this OP.

P.S. Incidentally, the text you supplied (from the POSIX specs) does appear
in "man bash" word-for-word (or very close to it). It is just formatted
differently. I mention this only for the benefit of OP, because, as I've said
this OP is very literal-minded.

--
Those on the right constantly remind us that America is not a
democracy; now they claim that Obama is a threat to democracy.

Re: Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)

<ssepco$201$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4873&group=comp.unix.shell#4873

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Don't need no stinkin' URLs (Was: About the exit status of the
`if' command.)
Date: Fri, 21 Jan 2022 18:09:44 +0100
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ssepco$201$1@dont-email.me>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
<ssegve$3eps9$1@news.xmission.com> <ssejua$jno$1@dont-email.me>
<ssemko$3ev4b$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jan 2022 17:09:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="81f2c5b36b78674faa7eb3594f8b717f";
logging-data="2049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+R4KA/+ZEtZGDymqkA1wO2"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:E/xhxTG0vGML3/YSXxTzzixtS48=
In-Reply-To: <ssemko$3ev4b$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 21 Jan 2022 17:09 UTC

On 21.01.2022 17:22, Kenny McCormack wrote:
> In article <ssejua$jno$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> ...
>> For basic standard stuff the POSIX specs are often better. The man
>> pages may differ (even for basic standard stuff) between shells.
>
> I would argue that the man page for one's specific shell is a better
> reference than the abstract POSIX specs. [...]

I basically agree with the first part. Though if the question is so
basic as the OP's one, concerning operational 'if'-semantics, then
I think POSIX might be better as the relevant reference. If, as you
say, these basics seem to be borrowed by the shells' man pages from
POSIX, yet the better. (It would be worse if shell's man pages would
in a subtle way deviate - like in the OP's quoted wording - and that
this deviation then spreads uncertainty and doubt.)
With the second part I wouldn't say that they, the POSIX specs, are
abstract. But YMMV, of course.

Janis

POSIX links (was Re: About the exit status of the `if' command.)

<sseq0j$78r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4874&group=comp.unix.shell#4874

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: POSIX links (was Re: About the exit status of the `if' command.)
Date: Fri, 21 Jan 2022 18:20:19 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <sseq0j$78r$1@dont-email.me>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me>
<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
<ssejb9$ekt$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jan 2022 17:20:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="81f2c5b36b78674faa7eb3594f8b717f";
logging-data="7451"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HnwYqRfb7m4b1Ga32yoTe"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:UgEy5Vv7XJgz7ssUfY/DOpN3OYk=
In-Reply-To: <ssejb9$ekt$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 21 Jan 2022 17:20 UTC

> On 21.01.2022 15:15, hongy...@gmail.com wrote:
>>
>> BTW, what's the URL [...]

Here are a couple links that you may want to inspect to get your
first qualified answers before you post.

For shell you may want to inspect

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html

where you also find a link to the shell language, accessible though

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18

And the entries to the standard Unix tools you find here

https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html

and for the often used and referenced standard awk see this page

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html

Hope that helps.

Janis

Re: POSIX links (was Re: About the exit status of the `if' command.)

<49946430-a9f4-4e1d-8056-36ed41096effn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4875&group=comp.unix.shell#4875

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:2307:: with SMTP id gc7mr6175856qvb.7.1642812483226;
Fri, 21 Jan 2022 16:48:03 -0800 (PST)
X-Received: by 2002:a37:5a43:: with SMTP id o64mr4729048qkb.375.1642812483064;
Fri, 21 Jan 2022 16:48:03 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 21 Jan 2022 16:48:02 -0800 (PST)
In-Reply-To: <sseq0j$78r$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me> <4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me> <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
<ssejb9$ekt$1@dont-email.me> <sseq0j$78r$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <49946430-a9f4-4e1d-8056-36ed41096effn@googlegroups.com>
Subject: Re: POSIX links (was Re: About the exit status of the `if' command.)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sat, 22 Jan 2022 00:48:03 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2471
 by: hongy...@gmail.com - Sat, 22 Jan 2022 00:48 UTC

On Saturday, January 22, 2022 at 1:20:24 AM UTC+8, Janis Papanagnou wrote:
> > On 21.01.2022 15:15, hongy...@gmail.com wrote:
> >>
> >> BTW, what's the URL [...]
>
> Here are a couple links that you may want to inspect to get your
> first qualified answers before you post.
>
> For shell you may want to inspect
>
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html
>
> where you also find a link to the shell language, accessible though
>
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18
>
> And the entries to the standard Unix tools you find here
>
> https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html
>
> and for the often used and referenced standard awk see this page
>
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html

Thank you for providing these links. Though the documentation and specs published by opengroup is famous and widely referred, its official stuff is not free and doesn't supply a friendly search interface for its massive knowledge base.
HZ

Re: Don't need no stinkin' URLs (Was: About the exit status of the `if' command.)

<67e3dad3-2994-426a-970c-9fad62109d16n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4876&group=comp.unix.shell#4876

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:15d6:: with SMTP id d22mr5420487qty.528.1642812564820;
Fri, 21 Jan 2022 16:49:24 -0800 (PST)
X-Received: by 2002:a05:6214:230d:: with SMTP id gc13mr2556378qvb.91.1642812564699;
Fri, 21 Jan 2022 16:49:24 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 21 Jan 2022 16:49:24 -0800 (PST)
In-Reply-To: <ssegve$3eps9$1@news.xmission.com>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com> <ssebh5$iji$1@dont-email.me>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com> <ssegve$3eps9$1@news.xmission.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <67e3dad3-2994-426a-970c-9fad62109d16n@googlegroups.com>
Subject: Re: Don't need no stinkin' URLs (Was: About the exit status of the
`if' command.)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sat, 22 Jan 2022 00:49:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2781
 by: hongy...@gmail.com - Sat, 22 Jan 2022 00:49 UTC

On Friday, January 21, 2022 at 10:46:11 PM UTC+8, Kenny McCormack wrote:
> In article <8834cc9c-bdca-4cf0...@googlegroups.com>,
> hongy...@gmail.com <hongy...@gmail.com> wrote:
> ...
> >BTW, what's the URL where you find the following explanation?
> >
> >> "Exit Status
> >> The exit status of the if command shall be the exit status of the then
> >> or else compound-list that was executed, or zero, if none was executed."
> Do "man bash", then search for: if
> (that's literally 5 spaces then i then f)

I can only see the following description:

$ man bash | grep -A7 ' if list'
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list is executed. If its exit status is zero, the then
list is executed. Otherwise, each elif list is executed in
turn, and if its exit status is zero, the corresponding then
list is executed and the command completes. Otherwise, the
else list is executed, if present. The exit status is the exit
status of the last command executed, or zero if no condition
tested true.


> And you'll get the 411.

What do you mean by saying 411 here?
> BTW, the above text does not appear literally in my "man bash" as written;
> I'm guessing that Janis got it from some other source. But the general
> content is the same.

Re: About the exit status of the `if' command.

<834k5vd5la.fsf@helmutwaitzmann.news.arcor.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4877&group=comp.unix.shell#4877

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!MM91jaUohWA0Q1TCTV4XlA.user.46.165.242.75.POSTED!not-for-mail
From: nn.throt...@xoxy.net (Helmut Waitzmann)
Newsgroups: comp.unix.shell
Subject: Re: About the exit status of the `if' command.
Date: Sat, 22 Jan 2022 18:48:33 +0100
Organization: Aioe.org NNTP Server
Message-ID: <834k5vd5la.fsf@helmutwaitzmann.news.arcor.de>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me>
<4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: gioia.aioe.org; logging-data="42698"; posting-host="MM91jaUohWA0Q1TCTV4XlA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Mail-Copies-To: nobody
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:y2W2lCTtqk/QGydnale943J+FyM=
Mail-Reply-To: Helmut Waitzmann Anti-Spam-Ticket.b.qc3c <oe.throttle@xoxy.net>
 by: Helmut Waitzmann - Sat, 22 Jan 2022 17:48 UTC

"hongy...@gmail.com" <hongyi.zhao@gmail.com>:
> On Friday, January 21, 2022 at 9:13:15 PM UTC+8, Janis Papanagnou
> wrote:
>> On 21.01.2022 13:59, hongy...@gmail.com wrote:
>>
>>> On Friday, January 21, 2022 at 8:25:26 PM UTC+8, Janis
>>> Papanagnou wrote:

>>>> You missed that no command has been executed. The 'if' compound
>>>> command would have executed the else case, but there isn't one.
>>>> Thus 0 is returned.
>>>
>>> Based on your above comments, I further noted the following
>>> description in help:
>>>
>>> The exit status of the entire construct is the exit status of
>>> the last command executed, or zero if no condition tested true.
>>>
>>> So, I obtained the following explanation: Given that the only
>>> condition "[ 1 -eq 2 ]" is false, we can say "no condition
>>> tested true" and therefore return zero.
>> I'm not sure why you formulate it that way. In case of
>>
>>
>> $ if [ 1 -eq 2 ]; then echo ok; else false ; fi ); echo $?
>> 1
>
> This is equivalent to:
>
By coincidence, yes.

> $ ( if [ 1 -eq 2 ]; then echo ok; else exit 1 ; fi ); echo $?
> 1

If, for example, you remove the parentheses, you'll get different
semantics.

>
>> there's also "no condition tested true" and you don't get exit
>> code 0. The point is another one. It's probably the best to
>> simply look up the POSIX specs where it's clearly described:
>>
>> "Exit Status
>> The exit status of the if command shall be the exit status of the
>> then or else compound-list that was executed, or zero, if none
>> was executed."
>
> So, if I want to obtain a valid exit status, it must be explicitly
> set by the then or else compound-list.

Not exactly.  It suffices to have the exit status implicitly be set
by the then or else compound‐list:  Every shell command (other than
the comment (#)) has got an exit status.  So there is no way not to
set an exit status.  It's the programmer's responsibility to have
the shell execute the right commands, though.

Re: About the exit status of the `if' command.

<4370cd51-e115-4977-984f-60c24a03d9bbn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4878&group=comp.unix.shell#4878

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:7dc5:: with SMTP id c5mr8465396qte.173.1642902089924;
Sat, 22 Jan 2022 17:41:29 -0800 (PST)
X-Received: by 2002:a05:622a:1106:: with SMTP id e6mr8414696qty.438.1642902089760;
Sat, 22 Jan 2022 17:41:29 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 22 Jan 2022 17:41:29 -0800 (PST)
In-Reply-To: <834k5vd5la.fsf@helmutwaitzmann.news.arcor.de>
Injection-Info: google-groups.googlegroups.com; posting-host=139.59.109.137; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 139.59.109.137
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<sse8nh$ukr$1@dont-email.me> <4caae896-9fb6-4b79-a6a6-c40159db1262n@googlegroups.com>
<ssebh5$iji$1@dont-email.me> <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
<834k5vd5la.fsf@helmutwaitzmann.news.arcor.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4370cd51-e115-4977-984f-60c24a03d9bbn@googlegroups.com>
Subject: Re: About the exit status of the `if' command.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Sun, 23 Jan 2022 01:41:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 34
 by: hongy...@gmail.com - Sun, 23 Jan 2022 01:41 UTC

On Sunday, January 23, 2022 at 8:25:32 AM UTC+8, Helmut Waitzmann wrote:
> "hongy...@gmail.com" <hongy...@gmail.com>:
> >> $ if [ 1 -eq 2 ]; then echo ok; else false ; fi ); echo $?
> >> 1
> >
> > This is equivalent to:
> >
> By coincidence, yes.
> > $ ( if [ 1 -eq 2 ]; then echo ok; else exit 1 ; fi ); echo $?
> > 1
> If, for example, you remove the parentheses, you'll get different
> semantics.

Aha, yep.

> >
> >> there's also "no condition tested true" and you don't get exit
> >> code 0. The point is another one. It's probably the best to
> >> simply look up the POSIX specs where it's clearly described:
> >>
> >> "Exit Status
> >> The exit status of the if command shall be the exit status of the
> >> then or else compound-list that was executed, or zero, if none
> >> was executed."
> >
> > So, if I want to obtain a valid exit status, it must be explicitly
> > set by the then or else compound-list.
> Not exactly. It suffices to have the exit status implicitly be set
> by the then or else compound‐list: Every shell command (other than
> the comment (#)) has got an exit status. So there is no way not to
> set an exit status. It's the programmer's responsibility to have
> the shell execute the right commands, though.

Thank you for the correction and elaboration on this conclusion.

Re: Don't need no stinkin' URLs

<rtsbci-lg21.ln1@wilbur.25thandClement.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4933&group=comp.unix.shell#4933

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 27 Jan 2022 19:30:02 -0600
Message-ID: <rtsbci-lg21.ln1@wilbur.25thandClement.com>
From: will...@25thandClement.com (William Ahern)
Subject: Re: Don't need no stinkin' URLs
Newsgroups: comp.unix.shell
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com> <8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com> <ssegve$3eps9$1@news.xmission.com> <ssejua$jno$1@dont-email.me> <ssemko$3ev4b$1@news.xmission.com>
User-Agent: tin/2.4.4-20191224 ("Millburn") (OpenBSD/6.9 (amd64))
Date: Thu, 27 Jan 2022 17:19:23 -0800
Lines: 90
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-eQx/gMgub5Cvc+tlxU8vR80lh+CuScsdeoQjqMj6QcsROiJR0FnGJW+ydaJPoTH5rLrIyRVBBCbtK7Z!HrvARkItS7+zxmEusekgkgXZH/1LtOW4qRM2jQqaG26UYqjqkjK8EyJaFZX8wy3TJ2Y=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 6613
 by: William Ahern - Fri, 28 Jan 2022 01:19 UTC

Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <ssejua$jno$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> ...
>>For basic standard stuff the POSIX specs are often better. The man
>>pages may differ (even for basic standard stuff) between shells.
>
> I would argue that the man page for one's specific shell is a better
> reference than the abstract POSIX specs. The POSIX specs tell you what
> *should* happen, while the man page will tell what *WILL* happen. The
> later is, in the real world, of much greater importance.

Bash has exceptionally strong POSIX compliance, particularly when it comes
to basic shell semantics. But the Bash manual page is rather difficult to
navigate, partly because so much is dedicated to all the various extension
features, and partly because there's no singular section that concisely
details the most basic semantics of the shell. Bash's info documentation
isn't much better--it literally has a section, "Shell Syntax", but it isn't
particularly helpful as most of the substance is described by reference to
other sections.

The POSIX specification is much more clear, IMHO, particularly with regard
to basic shell semantics. POSIX 1003.1-2017 volume 3, chapter 2, "Shell
Command Language", is the most concise *and* comprehensive description I've
yet seen of the Unix shell. This is especially true if you ignore the entire
second half (by length) of chapter 2, which is section 14, "Special Built-In
Utilities". Attentively spending 20-30 minutes reading sections 1-13, top to
bottom, can provide more substance and context than the vast majority of
people ever learn through experience and poking around vendor manual pages.
And after doing it once, whenever you're unsure about a behavior, you'll
know *exactly* where to navigate, as opposed to grep'ing through the manual
page, never being sure about unknown caveats and relationships described in
sections far removed.

I like the frame-based version of the spec at
https://pubs.opengroup.org/onlinepubs/9699919799. To navigate to the "Shell
Command Language" chapter, just click through "Shell & Utilities" in the
top-right, then "Shell Command Language" in the bottom-right. This presents
a navigation pane for chapter 2 in the bottom-right. For first timers with
30 minutes of free time, just click through "Shell Introduction" and begin
reading the main content frame. You can also download the frame-based
version locally, permitting you to literally grep the spec if necessary. I
rarely have such a need given the stellar organization, at least of the
shell in particular.

I have an untold number of specifications locally and bookmarked, and the
POSIX spec is by far one of the best organized resources. The only
comparable specifications that come to mind are the ISO C reference and
WHATWG's "living" HTML standard. Contrast C++, which isn't much useful
except for grep'ing. (Both C++ and HTML specs are styled as a literal
description of the functional steps a compiler takes, but WHATWG's execution
is far superior.) Or languages like Rust and Go, which don't even have a
proper specifications--when people rave about the documentation, they're
describing various tutorials and high-level references materials, which
while nice and aren't comparable--they lack the detail needed by programmers
doing anything non-trivial. You know this is so when the "documentation"
tends to more often change to fit surprising behavior, rather than the other
way around; and when people already familiar with the "documentation" still
spend an inordinate amount of time Google'ing for answers rather than first
going straight to the [supposedly] primary source. For Rust and Go, I more
often find myself reaching to papers and proposals describing behaviors of
interest. AFAIU, this is typical of Python as well--you have to discover and
read the PEP, which being an isolated document whose details can easily,
accidentally be superceded, is less than ideal.

> Particularly for someone as literal-minded and "I just want it to work"
> focused as this OP.

Maybe this is just me, but when "I just want it to work", one of the most
important considerations is developing a strong degree of confidence that I
don't need to worry about non-obvious caveats and exceptions; that is, that
it'll *actually* work. And the only way to get that--when you can get
that--is via a concise, well structured specification that makes discovering
potential caveats easy. This also requires a relatively stable object of the
specification, but fortunately the Unix shell has been relatively quite
stable in both its agreed-upon semantics and common implementations for
decades now.

Pendants can rattle off exceptions (see
https://austingroupbugs.net/view_all_bug_page.php), but they're irrelevant
and no worse than anything else comparable. Even the JSON spec and its
implementations, as simple as they should be, are plagued by such issues.

> P.S. Incidentally, the text you supplied (from the POSIX specs) does appear
> in "man bash" word-for-word (or very close to it). It is just formatted
> differently. I mention this only for the benefit of OP, because, as I've said
> this OP is very literal-minded.

That doesn't say much if you already know what you're looking for. The point
is discovering this stuff when you *don't* know what you're looking for.

Re: Don't need no stinkin' URLs

<m235l67wmr.fsf@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4939&group=comp.unix.shell#4939

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Re: Don't need no stinkin' URLs
Date: Sat, 29 Jan 2022 09:51:24 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <m235l67wmr.fsf@axel-reichert.de>
References: <acbe7139-d052-4a7e-bbf3-8601c810e870n@googlegroups.com>
<8834cc9c-bdca-4cf0-96cd-68818323b9bcn@googlegroups.com>
<ssegve$3eps9$1@news.xmission.com> <ssejua$jno$1@dont-email.me>
<ssemko$3ev4b$1@news.xmission.com>
<rtsbci-lg21.ln1@wilbur.25thandClement.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="81676c5856159639f3704a66abd1fdc4";
logging-data="32171"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JSQ+htcnFEtOZwx0kkQHApmuA06/6M5A="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin)
Cancel-Lock: sha1:NZDfqeedFg0Ei3NJ187OjlpyLtw=
sha1:fx55SIrltGrDdnWR08X7bmWaWI0=
 by: Axel Reichert - Sat, 29 Jan 2022 08:51 UTC

William Ahern <william@25thandClement.com> writes:

> But the Bash manual page is rather difficult to navigate, partly
> because so much is dedicated to all the various extension features,
> and partly because there's no singular section that concisely details
> the most basic semantics of the shell.

[...]

> The POSIX specification is much more clear, IMHO, particularly with
> regard to basic shell semantics. POSIX 1003.1-2017 volume 3, chapter
> 2, "Shell Command Language", is the most concise *and* comprehensive
> description I've yet seen of the Unix shell.

[...]

> Attentively spending 20-30 minutes reading sections 1-13, top to
> bottom, can provide more substance and context than the vast majority
> of people ever learn through experience and poking around vendor
> manual pages. And after doing it once, whenever you're unsure about a
> behavior, you'll know *exactly* where to navigate, as opposed to
> grep'ing through the manual page, never being sure about unknown
> caveats and relationships described in sections far removed.

[...]

> people already familiar with the "documentation" still spend an
> inordinate amount of time Google'ing for answers rather than first
> going straight to the [supposedly] primary source.

What a great piece of advocacy for "Read the source, Luke"! (With
"source" meaning not the code, but the reference documentation)

When Joerg Schily was still alive and kicking here, I learned for the
first time (in a warmed/heated discussion) that such stuff was available.
Before that, I grep'ed around in man pages, like you so aptly describe.

Thanks for this post!

Axel

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor