Bourne Shell Bug - Test

  • Follow


clerew% uname -a
SunOS clerew 5.10 Generic_118822-25 sun4u sparc SUNW,Ultra-2

Most implementations of 'test' allow "test -e somefilename", even though
the current Solaris 10 manpage does not mention it (only the -f, -d, etc
special cases). So I suppose the original Bell Labs version did not
include it, but in fact it works fine in /usr/bin/test as well as in the
later xpg4 version.  And Makefile scripts in the Linux world use -e
regularly.

The only place it does not work in the built-in version in Bourne Shell
(/bin/sh), which is a problem because 'make' (and 'gnumake') execute their
commands operate via /bin/sh unless you set the SHELL macro explicitly.

So ought Bourne Shell be fixed to mirror /usr/bin/test? Or is maintainig
the "purity" of Steve's original considered a "feature".

And why is the manpage so wrong (Last change: 5 Jul 1990)?

Test case:

clerew% /bin/sh -c 'test -e /tmp && echo tmp-seen'
/bin/sh: test: argument expected
clerew% /usr/bin/test -e /tmp && echo tmp-seen
tmp-seen

-- 
Charles H. Lindsey ---------At Home, doing my own thing------------------------
Tel: +44 161 436 6131            Web: http://www.cs.man.ac.uk/~chl
Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5
0
Reply Charles 7/16/2009 4:21:12 PM

"Charles Lindsey"  wrote:

> So ought Bourne Shell be fixed to mirror /usr/bin/test? Or is maintainig
> the "purity" of Steve's original considered a "feature".

Note that -e is required by posix, but the posix shell doesn't have to be
located in /bin/sh.

The question of keeping the old /bin/sh or replacing it with something
more modern regularly causes heated discussions. Opensolaris boldly
replaced it with ksh93, so there is a chance the same will be done in
solaris 11. Enhancing the old /bin/sh doesn't look like a very popular
option (J�rg Schilling did some enhancements for his own distro, but they
haven't been included more globally).

> And why is the manpage so wrong (Last change: 5 Jul 1990)?

              -e file
                    True if file exists. (Not available in sh.)

What's wrong?
0
Reply Marc 7/17/2009 7:47:01 AM


"Marc" <marc.glisse@gmail.com> wrote in message news:h3pa9l$mko$1@nef.ens.fr...
>
> The question of keeping the old /bin/sh or replacing it with something
> more modern regularly causes heated discussions. Opensolaris boldly
> replaced it with ksh93, so there is a chance the same will be done in
> solaris 11.

Not very bold given that OpenSolaris is generally run on laptops since
a year or two ago, so hardly has to worry about impacting decades
old shell scripts on enterprise servers in corporate data centres.


0
Reply John 7/17/2009 1:14:32 PM

In <h3pa9l$mko$1@nef.ens.fr> Marc <marc.glisse@gmail.com> writes:

>"Charles Lindsey"  wrote:

>> So ought Bourne Shell be fixed to mirror /usr/bin/test? Or is maintainig
>> the "purity" of Steve's original considered a "feature".

>Note that -e is required by posix, but the posix shell doesn't have to be
>located in /bin/sh.

And that seems to be the problem, because that is where applications
(notably 'make') look in order to find the "default sensible shell". So
what/where is the "official Posix shell". And what is /bin/sh supposed to
point to (that being what shell scripts always oinvoke by long-standing
tradition)? In Solaris, it seems to point to /sbin/sh, but that is just
another vanilla Bourne.

But since "Bourne shell" is the traditional basic shell, then whatever is
offered as such in any respectable installation simply MUST be whatever
POSIX requires. I cannot see what harm would arise by not bringing
whatever is offered in /usr/bin/sh up to that standard.

And indeed there exists /usr/xpg4/bin/sh, but that is 99.9% the same as
ksh.

But /usr/ccs/make claims to call "Bourne shell" (i.e. /ust/nin/sh).
sysV-make(1) uses whatever in in $SHELL (default /usr/bin/sh, and would be
csh in my case :-( ).

There also exists /usr/xpg4/bin/make, and that does indeed do the "right
thing" (hooray!). But the Bad News is that I can't find any Man Page for
it.

>The question of keeping the old /bin/sh or replacing it with something
>more modern regularly causes heated discussions. Opensolaris boldly
>replaced it with ksh93, so there is a chance the same will be done in
>solaris 11. Enhancing the old /bin/sh doesn't look like a very popular
>option (J�rg Schilling did some enhancements for his own distro, but they
>haven't been included more globally).

Yes, J�rg likes to make indelendent forks of various well-known software,
but gets terribly upset when people make independent forks of his own
stuff :-( .

>> And why is the manpage so wrong (Last change: 5 Jul 1990)?

>              -e file
>                    True if file exists. (Not available in sh.)

>What's wrong?

Ah! I was looking at the test(1F) manual page, which appears to be a part
of the FMLI system (of which I had never heard before), which my Manual
Viewer seems to bring up in preference to test(1). I shall have to fix
that :-(.

-- 
Charles H. Lindsey ---------At Home, doing my own thing------------------------
Tel: +44 161 436 6131            Web: http://www.cs.man.ac.uk/~chl
Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5
0
Reply Charles 7/20/2009 8:19:55 PM

Marc wrote:
> "Charles Lindsey"  wrote:

>> ["test -e somefilename"]
>> the current Solaris 10 manpage does not mention it (only the -f, -d, etc
>> special cases). So I suppose the original Bell Labs version did not
>> include it [...]

Yes, it was not available in Bourne shells, except a vendor
added it individually (e.g. OSF1, OpenServer 5, IRIX 5).
I believe 4.4BSD implemented test -e originally.

Interestingly, Sun added "-L" (an alias for "-h") with SunOS 5.9.
Sun actually added numerous (about 20) fixes to the Bourne shell *),
but almost always bugfixes.  Convenience was not the motivation.

Missing "-e" is not a real bug, because #!/bin/sh scripts ("traditional
portability") shouldn't have used it, anyway.  They might handle it like
"-L" if getting noticed?

> Enhancing the old /bin/sh doesn't look like a very popular option
> (J�rg Schilling did some enhancements for his own distro, but they
> haven't been included more globally).

These are rather history and command line editor fixes for interactive
usage which didn't seem Sun's focus (for /bin/sh) for their changes.

-- 
*) http://www.in-ulm.de/~mascheck/bourne/#sunos5
0
Reply Sven 7/20/2009 11:13:05 PM

On 2009-07-20 21:19:55 +0100, "Charles Lindsey" <chl@clerew.man.ac.uk> said:

> In <h3pa9l$mko$1@nef.ens.fr> Marc <marc.glisse@gmail.com> writes:
> 
>> "Charles Lindsey"  wrote:
> 
>>> So ought Bourne Shell be fixed to mirror /usr/bin/test? Or is maintainig
>>> the "purity" of Steve's original considered a "feature".
> 
>> Note that -e is required by posix, but the posix shell doesn't have to be
>> located in /bin/sh.
> 
> And that seems to be the problem, because that is where applications
> (notably 'make') look in order to find the "default sensible shell". So
> what/where is the "official Posix shell". And what is /bin/sh supposed to

POSIX provides a std way to get a PATH which includes POSIX-conformant tools:

getconf PATH

So do PATH=`getconf PATH` in your sh scripts and so on...

> There also exists /usr/xpg4/bin/make, and that does indeed do the "right
> thing" (hooray!). But the Bad News is that I can't find any Man Page for
> it.

The normal man page for make also documents the POSIX-conformant make.
-- 
Chris

0
Reply Chris 7/21/2009 6:33:53 AM

In <7cl5qhF28j6b2U1@mid.individual.net> Chris Ridd <chrisridd@mac.com> writes:

>On 2009-07-20 21:19:55 +0100, "Charles Lindsey" <chl@clerew.man.ac.uk> said:

>> And that seems to be the problem, because that is where applications
>> (notably 'make') look in order to find the "default sensible shell". So
>> what/where is the "official Posix shell". And what is /bin/sh supposed to

>POSIX provides a std way to get a PATH which includes POSIX-conformant tools:

>getconf PATH

>So do PATH=`getconf PATH` in your sh scripts and so on...

But which version of getconf should I call. I can see
     /usr/bin/getconf
     /usr/xpg4/bin/getconf
     /usr/xpg6/bin/getconf
And don't tell me "whichever is in you PATH" :-( .

And the manpage is silent on what the differences are between them. And it
is totally unclear what the '-v' option is supposed to do.

>> There also exists /usr/xpg4/bin/make, and that does indeed do the "right
>> thing" (hooray!). But the Bad News is that I can't find any Man Page for
>> it.

>The normal man page for make also documents the POSIX-conformant make.

Yes, but it is not very clear about the differences, particularly on what
difference it makes to which shell it calls. The only documented effect is
on the list of makfeile names it looks for if no -f flag is given.

-- 
Charles H. Lindsey ---------At Home, doing my own thing------------------------
Tel: +44 161 436 6131            Web: http://www.cs.man.ac.uk/~chl
Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5
0
Reply Charles 7/22/2009 3:32:34 PM

Charles Lindsey <chl@clerew.man.ac.uk> wrote:

(clippage)

> But since "Bourne shell" is the traditional basic shell, then whatever is
> offered as such in any respectable installation simply MUST be whatever
> POSIX requires. I cannot see what harm would arise by not bringing
> whatever is offered in /usr/bin/sh up to that standard.

This is a mistaken assumption, if I understand you.

Nothing about the (original) Bourne Shell is inherently POSIX-compliant.
/bin/sh MUST be 100% Bourne Shell compatible. If programs require POSIX
behaviour, they must check for it, or be configurable.
0
Reply Colin 7/22/2009 6:30:41 PM

On Wed, 22 Jul 2009 15:32:34 GMT, Charles Lindsey <chl@clerew.man.ac.uk> wrote:
> In <7cl5qhF28j6b2U1@mid.individual.net> Chris Ridd <chrisridd@mac.com> writes:
>
>>On 2009-07-20 21:19:55 +0100, "Charles Lindsey" <chl@clerew.man.ac.uk> said:
>
>>> And that seems to be the problem, because that is where applications
>>> (notably 'make') look in order to find the "default sensible shell". So
>>> what/where is the "official Posix shell". And what is /bin/sh supposed to
>
>>POSIX provides a std way to get a PATH which includes POSIX-conformant tools:
>
>>getconf PATH
>
>>So do PATH=`getconf PATH` in your sh scripts and so on...
>
> But which version of getconf should I call. I can see
>      /usr/bin/getconf
>      /usr/xpg4/bin/getconf
>      /usr/xpg6/bin/getconf
> And don't tell me "whichever is in you PATH" :-( .

I have

PATH=$(/usr/xpg6/bin/getconf PATH):[other bits]

in my ksh93 .profile.

I'm not sure about /usr/bin/getconf, but the other two obviously give
you PATHs conforming to XPG4 and XPG6.

A bientot
Paul
-- 
Paul Floyd                 http://paulf.free.fr
0
Reply Paul 7/22/2009 8:14:27 PM

In <slrnh6et4s.2c5.root@tryfan.orange.fr> Paul Floyd <root@127.0.0.1> writes:

>On Wed, 22 Jul 2009 15:32:34 GMT, Charles Lindsey <chl@clerew.man.ac.uk> wrote:
>> In <7cl5qhF28j6b2U1@mid.individual.net> Chris Ridd <chrisridd@mac.com> writes:
>>
>>>So do PATH=`getconf PATH` in your sh scripts and so on...
>>
>> But which version of getconf should I call. I can see
>>      /usr/bin/getconf
>>      /usr/xpg4/bin/getconf
>>      /usr/xpg6/bin/getconf
>> And don't tell me "whichever is in you PATH" :-( .

>I have

>PATH=$(/usr/xpg6/bin/getconf PATH):[other bits]

>in my ksh93 .profile.

>I'm not sure about /usr/bin/getconf, but the other two obviously give
>you PATHs conforming to XPG4 and XPG6.

/usr/bin/getconf tells you to use /usr/xpg4/bin (as does
/usr/xpg4/bin/getconf).

/usr/xpg6/bin/getconf tells you to use /usr/xpg6/bin.

But what are the relative merits of xpg4 and xpg6? ISTM that spg6 takes
you to a recent revisions of POSIX 1, whereas XPG4 take you to POSIX 2.
But which one do I _really_ WANT?

-- 
Charles H. Lindsey ---------At Home, doing my own thing------------------------
Tel: +44 161 436 6131            Web: http://www.cs.man.ac.uk/~chl
Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5
0
Reply Charles 7/23/2009 11:51:22 AM

In <lVI9m.30342$O23.19123@newsfe11.iad> "Colin B." <cbigam@somewhereelse.shaw.ca> writes:

>Charles Lindsey <chl@clerew.man.ac.uk> wrote:

>(clippage)

>> But since "Bourne shell" is the traditional basic shell, then whatever is
>> offered as such in any respectable installation simply MUST be whatever
>> POSIX requires. I cannot see what harm would arise by not bringing
>> whatever is offered in /usr/bin/sh up to that standard.

>This is a mistaken assumption, if I understand you.

>Nothing about the (original) Bourne Shell is inherently POSIX-compliant.
>/bin/sh MUST be 100% Bourne Shell compatible. If programs require POSIX
>behaviour, they must check for it, or be configurable.

I agree that whatever was _defined_ to work in Bourne Shell must continue
to work in /bin/sh. But the case we are talking about (test -e filename)
was meaningless in the original Bourne Shell, so I see no harm in letting
/bin/sh (or rather /usr/bin/sh) implement it correctly, especially as
things (e.g /usr/ccs/bin/make but not /usr/xpg4/binb/make) break
otherwise.

-- 
Charles H. Lindsey ---------At Home, doing my own thing------------------------
Tel: +44 161 436 6131            Web: http://www.cs.man.ac.uk/~chl
Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5
0
Reply Charles 7/23/2009 11:56:30 AM

On Thu, 23 Jul 2009 11:51:22 GMT, Charles Lindsey <chl@clerew.man.ac.uk> wrote:
>
> But what are the relative merits of xpg4 and xpg6? ISTM that spg6 takes
> you to a recent revisions of POSIX 1, whereas XPG4 take you to POSIX 2.
> But which one do I _really_ WANT?

I dunno. No crystal ball here. Personally I prefer the latest versions
of SUS/XPG. Generally they cover more things.

A bientot
Paul
-- 
Paul Floyd                 http://paulf.free.fr
0
Reply Paul 7/24/2009 6:06:52 PM

In article <Kn3KH7.2yv@clerew.man.ac.uk>,
Charles Lindsey <chl@clerew.man.ac.uk> wrote:
....
....
>>haven't been included more globally).
>
>Yes, J�rg likes to make indelendent forks of various well-known software,
>but gets terribly upset when people make independent forks of his own
>stuff :-( .
>
>>> And why is the manpage so wrong (Last change: 5 Jul 1990)?
>
>>              -e file
>>                    True if file exists. (Not available in sh.)
>
>>What's wrong?
>
>Ah! I was looking at the test(1F) manual page, which appears to be a part
>of the FMLI system (of which I had never heard before), which my Manual
>Viewer seems to bring up in preference to test(1). I shall have to fix
>that :-(.
>
>-- 
>Charles H. Lindsey ---------At Home, doing my own thing------------------------
>Tel: +44 161 436 6131            Web: http://www.cs.man.ac.uk/~chl
>Email: chl@clerew.man.ac.uk      Snail: 5 Clerewood Ave, CHEADLE, SK8 3JU, U.K.
>PGP: 2C15F1A9      Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5


PLEASE, whatever changes you make to these various man-pages, POST THEM HERE
TOO, also telling us where the ORIGINAL man-pages were, and IF you have time,
what's IMPORTANT about the man-page modifications.

THANK YOU!!!

Oh, also with a subject-line like "SOME xyz and abc MAN-PAGE ERRORS FIXED, HERE".

Maybe also add the word "IMPORTANT!:" (if you and most people here
agree).


Thanks,

David




0
Reply dkcombs 8/10/2009 10:54:25 PM

Yep, it was that missing "DOMAIN FOO" line!


THANKS TO ALL OF YOU GUYS!

AND TO RICHARD GILBERT, WHO FINALLY HIT THE SOLULTION --
  that missing DOMAIN xyz line.


Can't get hold of my friend tonight, but when I tell him,
there's probably a loud SLAP sound coming through the 
phone!   :-)


THANK YOU!  YOU ALL SAVED THE DAY!



David


0
Reply dkcombs 8/13/2009 5:31:45 AM

13 Replies
122 Views

(page loaded in 0.767 seconds)

Similiar Articles:




7/20/2012 4:10:50 AM


Reply: