* if then elif then else fi -- Problem report
@ 2010-06-28 12:56 Malcolm Kay
2010-06-28 13:22 ` Eric Blake
0 siblings, 1 reply; 7+ messages in thread
From: Malcolm Kay @ 2010-06-28 12:56 UTC (permalink / raw)
To: dash
I notice that 'dash' fails on many scripts that ran okay with
the traditional Bourne shell 'sh'.
On closer examination I find that it does not conform to any
of the man pages that I've been able to find for 'dash'.
Should I create a problem report? Where should I send it?
The particular version is dash-0.5.5.1 running on
FreeBSD xi.home 8.0-RELEASE FreeBSD 8.0-RELEASE #0:
Sat Nov 21 15:48:17 UTC 2009
I have a report that the same trouble occurs in the 'dash'
as shipped with Ubuntu 10.04 Lucid Lynx.
The problem is that 'dash' bombs out with an empty list in:
if ...
then
list
elif ...
then
list
fi
or in:
if ...
then
list
else
list
fi
The latter gives for example:
Syntax error: "else" unexpected.
Yet the man pages clearly state that a list consists of zero
or more commands --
<quote>
Lists -- Generally Speaking
A list is a sequence of zero or more commands separated by
newlines,
semicolons, or ampersands, and optionally terminated by one
of these
three characters.
</quote>
Should I create a problem report? Where should I send it?
Cheers,
Malcolm
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: if then elif then else fi -- Problem report 2010-06-28 12:56 if then elif then else fi -- Problem report Malcolm Kay @ 2010-06-28 13:22 ` Eric Blake 2010-06-29 1:08 ` Malcolm Kay 0 siblings, 1 reply; 7+ messages in thread From: Eric Blake @ 2010-06-28 13:22 UTC (permalink / raw) To: Malcolm Kay; +Cc: dash [-- Attachment #1: Type: text/plain, Size: 1081 bytes --] On 06/28/2010 06:56 AM, Malcolm Kay wrote: > Should I create a problem report? Where should I send it? You just did. > The problem is that 'dash' bombs out with an empty list in: > > if ... > then > list > elif ... > then > list > fi > > or in: > > if ... > then > list > else > list > fi POSIX requires a non-empty list in these syntax setups. > The latter gives for example: > Syntax error: "else" unexpected. Correct. > Yet the man pages clearly state that a list consists of zero > or more commands -- > <quote> > Lists -- Generally Speaking > A list is a sequence of zero or more commands separated by > newlines, Therefore, the bug is in the man page. Per POSIX, http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_03 "A list is a sequence of one or more AND-OR lists separated by the operators ';' and '&' and optionally terminated by ';' , '&' , or <newline>." -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 619 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: if then elif then else fi -- Problem report 2010-06-28 13:22 ` Eric Blake @ 2010-06-29 1:08 ` Malcolm Kay 2010-06-29 12:56 ` Eric Blake 2010-07-04 21:50 ` Sven Mascheck 0 siblings, 2 replies; 7+ messages in thread From: Malcolm Kay @ 2010-06-29 1:08 UTC (permalink / raw) To: Eric Blake; +Cc: dash Eric, Thanks for the clarification. I had assumed that 'dash' aimed to be a faster replacement for the classical Bourne shell 'sh' as implemented in BSD systems, and this seemed to be confirmed when all the man pages I've been able to find were more or less direct copies of BSD 'sh' pages. As it is I feel the man pages should not only be fixed in this respect, but also such differences to classical 'sh' implementations should be high lighted. On Mon, 28 Jun 2010 10:52 pm, Eric Blake wrote: > . . . > > Therefore, the bug is in the man page. Per POSIX, > http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_ch >ap02.html#tag_18_09_03 "A list is a sequence of one or more > AND-OR lists separated by the operators ';' and '&' and > optionally terminated by ';' , '&' , or <newline>." While I agree with your conclusions, I would note that POSIX defines "if ... else etc." in terms of 'compound_list' rather than 'list' so the above definition of 'list' is not really relevant. By my reading of your reference it seems POSIX defines 'list' and 'compound_list' independently but fails to clarify the difference if any. Malcolm ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: if then elif then else fi -- Problem report 2010-06-29 1:08 ` Malcolm Kay @ 2010-06-29 12:56 ` Eric Blake 2010-07-04 21:50 ` Sven Mascheck 1 sibling, 0 replies; 7+ messages in thread From: Eric Blake @ 2010-06-29 12:56 UTC (permalink / raw) To: Malcolm Kay; +Cc: dash [-- Attachment #1: Type: text/plain, Size: 2520 bytes --] On 06/28/2010 07:08 PM, Malcolm Kay wrote: > Eric, > Thanks for the clarification. > > I had assumed that 'dash' aimed to be a faster replacement for > the classical Bourne shell 'sh' as implemented in BSD systems, Rather, 'dash' aims to be the fastest and smallest possible POSIX-compliant shell; anywhere that POSIX disagrees with traditional Bourne shell behavior, POSIX triumphs. Not all BSD system /bin/sh are POSIX compliant. And while dash has some extensions over POSIX, the goal of being smallest means that extensions are kept to a minimum (contrast that with bash or zsh, which both have a goal of providing as many useful extensions as possible at the expense of size and sometimes speed). > As it is I feel the man pages should not only be fixed in this > respect, but also such differences to classical 'sh' > implementations should be high lighted. There are other existing online resources that describe differences between Bourne shell and POSIX. But it is a much bigger effort to document how dash differs from non-POSIX shells than it is to just document how dash itself behaves. > > On Mon, 28 Jun 2010 10:52 pm, Eric Blake wrote: >> . . . >> >> Therefore, the bug is in the man page. Per POSIX, >> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_ch >> ap02.html#tag_18_09_03 "A list is a sequence of one or more >> AND-OR lists separated by the operators ';' and '&' and >> optionally terminated by ';' , '&' , or <newline>." > > While I agree with your conclusions, I would note that POSIX > defines "if ... else etc." in terms of 'compound_list' rather > than 'list' so the above definition of 'list' is not really > relevant. By my reading of your reference it seems POSIX defines > 'list' and 'compound_list' independently but fails to clarify > the difference if any. POSIX defines compound_list quite clearly. Read the grammar section: http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02 compound_list : term | newline_list term | term separator | newline_list term separator It also defines list: list : list separator_op and_or | and_or The difference between the two is how newlines serve to separate the various and_or lists. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 619 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: if then elif then else fi -- Problem report 2010-06-29 1:08 ` Malcolm Kay 2010-06-29 12:56 ` Eric Blake @ 2010-07-04 21:50 ` Sven Mascheck 2010-07-06 7:48 ` Malcolm Kay 1 sibling, 1 reply; 7+ messages in thread From: Sven Mascheck @ 2010-07-04 21:50 UTC (permalink / raw) To: dash On Tue, Jun 29, 2010 at 10:38:31AM +0930, Malcolm Kay wrote: > I had assumed that 'dash' aimed to be a faster replacement for > the classical Bourne shell 'sh' as implemented in BSD systems, > and this seemed to be confirmed when all the man pages I've been > able to find were more or less direct copies of BSD 'sh' pages. The original ash (at the time of 4.3BSD-Net2) was such a replacement of the SVR4 Bourne shell. But with the next "traditional" BSD release, 4.4BSD alpha, the shell was already aiming at POSIX; and so were the shells on NetBSD (1.0 ff) and FreeBSD, soon. However, there is a relation from 4.3BSD-Net2, 386BSD, earlyNetBSD to a Linux port, and thus a Bourne-like ash interestingly survived with Slackware until 2007 (8.1). dash in contrast was an independent, later port from NetBSD to Linux and was a modern variant from the start. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: if then elif then else fi -- Problem report 2010-07-04 21:50 ` Sven Mascheck @ 2010-07-06 7:48 ` Malcolm Kay 2010-07-06 20:49 ` Sven Mascheck 0 siblings, 1 reply; 7+ messages in thread From: Malcolm Kay @ 2010-07-06 7:48 UTC (permalink / raw) To: mascheck; +Cc: dash On Mon, 5 Jul 2010 07:20 am, Sven Mascheck wrote: > On Tue, Jun 29, 2010 at 10:38:31AM +0930, Malcolm Kay wrote: > > I had assumed that 'dash' aimed to be a faster replacement > > for the classical Bourne shell 'sh' as implemented in BSD > > systems, and this seemed to be confirmed when all the man > > pages I've been able to find were more or less direct copies > > of BSD 'sh' pages. > > The original ash (at the time of 4.3BSD-Net2) was such a > replacement of the SVR4 Bourne shell. But with the next > "traditional" BSD release, 4.4BSD alpha, the shell was already > aiming at POSIX; and so were the shells on NetBSD (1.0 ff) and > FreeBSD, soon. I recall seeing and even playing with an implementation of the Almquist shell 'ash' in the mid 1980's but as it was running on an unimpressive/unsuitable operating system (DRDOS/TOS) it was not really very inspiring. Later I picked up a microVAX with Ultrix 4, I still have the manuals. The man pages reference sh(1) as "the standard Bourne shell interpreter" and sh5(1) as a "version of the shell from System V version 2". In general the sh(1) pages has seemed to conform fairly closely to 'sh' as found on modern BSD operating systems. But now that I look more closely I find that both the Ultrix man pages define a list as "one or more ..." , rather the "zero or more ..." as in later man pages -- so it would seem at least in that respect the Ultrix corresponds more closely to what was then a not yet existing POSIX standard. In a way I do find this rather surprising as POSIX appeared in an era when languages such as fortran and basic which started counting at one were becoming displaced (admittedly rather slowly) by languages that incorporated zero, C, pascal and virtually all the modern OOP languages. > > However, there is a relation from 4.3BSD-Net2, 386BSD, > earlyNetBSD to a Linux port, and thus a Bourne-like ash > interestingly survived with Slackware until 2007 (8.1). > > dash in contrast was an independent, later port from NetBSD to > Linux and was a modern variant from the start. History can be interesting and sometimes somewhat surpising. Malcolm ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: if then elif then else fi -- Problem report 2010-07-06 7:48 ` Malcolm Kay @ 2010-07-06 20:49 ` Sven Mascheck 0 siblings, 0 replies; 7+ messages in thread From: Sven Mascheck @ 2010-07-06 20:49 UTC (permalink / raw) To: dash On Tue, Jul 06, 2010 at 05:18:54PM +0930, Malcolm Kay wrote: > I recall seeing and even playing with an implementation of > the Almquist shell 'ash' in the mid 1980's but as it was running > on an unimpressive/unsuitable operating system (DRDOS/TOS) That must have been a different shell, because the Almquist shell was introduced '89. > Later I picked up a microVAX with Ultrix 4, I still have the > manuals. The man pages reference sh(1) as "the standard Bourne > shell interpreter" and sh5(1) as a "version of the shell from > System V version 2". Ultrix sh is a variant of the 7th edition shell, the original Bourne shell. (Ultrix eventually got somewhat famous for coming with such an old variant as /bin/sh, because it had not even implemented functions, yet). Ultrix sh5 is a later variant of the same family, which was mainly added because it had functions. If you want to have a glance at such relationsships from the past: http://www.in-ulm.de/~mascheck/various/ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-07-06 20:49 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-06-28 12:56 if then elif then else fi -- Problem report Malcolm Kay 2010-06-28 13:22 ` Eric Blake 2010-06-29 1:08 ` Malcolm Kay 2010-06-29 12:56 ` Eric Blake 2010-07-04 21:50 ` Sven Mascheck 2010-07-06 7:48 ` Malcolm Kay 2010-07-06 20:49 ` Sven Mascheck
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.