Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Science is what happens when preconception meets verification.


devel / comp.unix.shell / do-list optional in Bourne shell while loop?

SubjectAuthor
* do-list optional in Bourne shell while loop?Edward McGuire
`* Re: do-list optional in Bourne shell while loop?Janis Papanagnou
 `- Re: do-list optional in Bourne shell while loop?Edward McGuire

1
do-list optional in Bourne shell while loop?

<2e2b30ae-eac2-4f07-bfc0-a7aac6639b48n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:6c81:0:b0:702:1fee:571d with SMTP id h123-20020a376c81000000b007021fee571dmr2924059qkc.253.1673381431321;
Tue, 10 Jan 2023 12:10:31 -0800 (PST)
X-Received: by 2002:a05:6808:3a3:b0:35b:4cbf:b9e9 with SMTP id
n3-20020a05680803a300b0035b4cbfb9e9mr4014710oie.127.1673381431035; Tue, 10
Jan 2023 12:10:31 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.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: Tue, 10 Jan 2023 12:10:30 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=70.117.52.110; posting-account=99-szAoAAABeqjQXkwq9U3xS8fVveYhv
NNTP-Posting-Host: 70.117.52.110
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2e2b30ae-eac2-4f07-bfc0-a7aac6639b48n@googlegroups.com>
Subject: do-list optional in Bourne shell while loop?
From: met...@gmail.com (Edward McGuire)
Injection-Date: Tue, 10 Jan 2023 20:10:31 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1592
 by: Edward McGuire - Tue, 10 Jan 2023 20:10 UTC

I was reading manual pages for Bourne shell, and was surprised to see the syntax of while-done documented as "while list [ do list ] done". The surprise is that the do-list is bracketed (optional).

The brackets appear in the Unix Version 7 manual page published by Sven Mascheck (https://www.in-ulm.de/~mascheck/bourne/v7/), and in the manual page released by Gunnar Ritter with the Heirloom Bourne shell (https://heirloom.sourceforge.net/sh/sh.1.html).

Is this just a long-standing documentation bug? The Heirloom shell actually throws a syntax error when its input is "while true ; done".

Re: do-list optional in Bourne shell while loop?

<tplc4k$q0qd$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: do-list optional in Bourne shell while loop?
Date: Wed, 11 Jan 2023 04:58:11 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <tplc4k$q0qd$1@dont-email.me>
References: <2e2b30ae-eac2-4f07-bfc0-a7aac6639b48n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 11 Jan 2023 03:58:12 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9b85141b195ce8ad36300ee779cfdfbc";
logging-data="852813"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7m3PqAeNcNhEmxI82wpd3"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:AjfgI95F/bMzH/OGeOzZTygPfYA=
X-Enigmail-Draft-Status: N1110
X-Mozilla-News-Host: news://news.eternal-september.org
In-Reply-To: <2e2b30ae-eac2-4f07-bfc0-a7aac6639b48n@googlegroups.com>
 by: Janis Papanagnou - Wed, 11 Jan 2023 03:58 UTC

On 10.01.2023 21:10, Edward McGuire wrote:
> I was reading manual pages for Bourne shell, and was surprised to see
> the syntax of while-done documented as "while list [ do list ] done".
> The surprise is that the do-list is bracketed (optional).
>
> The brackets appear in the Unix Version 7 manual page published by
> Sven Mascheck (https://www.in-ulm.de/~mascheck/bourne/v7/), and in
> the manual page released by Gunnar Ritter with the Heirloom Bourne
> shell (https://heirloom.sourceforge.net/sh/sh.1.html).
>
> Is this just a long-standing documentation bug? The Heirloom shell
> actually throws a syntax error when its input is "while true ;
> done".

Is it [in Unix Version 7] a bug? - I suppose we'd need some old
(original) Bourne shell to test its behavior. - If it would work
in that old shell it could be considered an implementation error
in the clone. Code like i=5 ; while echo $i ; let i=i-1 ; done
would work. Anyway. Being curious I had a peek into the C source
code and (as far as I understood the macro'ized C code correctly)
the while statement expects a 'do' and a 'done'. A comment at the
beginning lists as an "item": "for ... while ... do ... done" ,
a syntax that resembles the Algol 68 generalized loop; which may
(as far as I can tell) be defined formally like
[ for v ] [ from f ] [ by b ] [ to t ] [ while w ] do s od
where almost everything is optional but the 'do' part. Despite
the Algol like "item" in Bourne shell 'for' and 'while' seem to
be separate commands (as we also know from the shell successors).
Interestingly I noticed that the 'for' loop does not seem to need
'do' and 'done'; these can be replaced by braces! - And that is
obviously still supported by some of the modern shells (ksh, zsh,
bash, but not, e.g., by ash):

$ for i in a b ; { echo $i ; }
a
b

(though this seems undocumented). - Funny anyway, and new to me.

Janis

Re: do-list optional in Bourne shell while loop?

<5456af41-c8db-467b-811a-ba4682f8d989n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:4e1:b0:6fe:df47:44f5 with SMTP id b1-20020a05620a04e100b006fedf4744f5mr3973254qkh.416.1673476066988;
Wed, 11 Jan 2023 14:27:46 -0800 (PST)
X-Received: by 2002:a05:6870:ed43:b0:150:9aec:cd74 with SMTP id
ex3-20020a056870ed4300b001509aeccd74mr2717608oab.219.1673476066710; Wed, 11
Jan 2023 14:27:46 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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: Wed, 11 Jan 2023 14:27:46 -0800 (PST)
In-Reply-To: <tplc4k$q0qd$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=70.117.52.110; posting-account=99-szAoAAABeqjQXkwq9U3xS8fVveYhv
NNTP-Posting-Host: 70.117.52.110
References: <2e2b30ae-eac2-4f07-bfc0-a7aac6639b48n@googlegroups.com> <tplc4k$q0qd$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5456af41-c8db-467b-811a-ba4682f8d989n@googlegroups.com>
Subject: Re: do-list optional in Bourne shell while loop?
From: met...@gmail.com (Edward McGuire)
Injection-Date: Wed, 11 Jan 2023 22:27:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1460
 by: Edward McGuire - Wed, 11 Jan 2023 22:27 UTC

On Tuesday, January 10, 2023 at 9:58:18 PM UTC-6, Janis Papanagnou wrote:
> the 'for' loop does not seem to need
> 'do' and 'done'; these can be replaced by braces! - And that is
> obviously still supported by some of the modern shells (ksh, zsh,
> bash, but not, e.g., by ash)

Great find, I had no idea.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor