On 2008-11-30, Stephane Chazelas <[EMAIL PROTECTED]> wrote: > 2008-11-30, 06:11(+00), Tam Ha: >> Stephane CHAZELAS wrote: >>> There's a common confusion in this in the nature of /bin/sh. >>> There's no standard (neither POSIX nor Unix) that specifies that >>> /bin/sh should be any variant of the Bourne shell. >> >> Sure there is, POSIX. > [...] > > And on this. First, POSIX has no juridiction on defining the > Bourne shell, let alone its location as the Bourne shell is > completely outside POSIX, it's a legacy shell and as been for > years. Then, POSIX makes it clear that the location of its sh > utility (again, which the Bourne shell is not) is unspecified, > only that the lookup of "sh" via $PATH in a conformant > environment should resolve to a conformant "sh". > > And if you need some examples to be convinced, see the different > choices of those 4 different POSIX conformant Unices: > > Solaris (7, 8, 9 at least): > /bin/sh: legacy Bourne/SVr4 shell > /usr/xpg4/bin/sh: a POSIX compliant shell (actually ksh88) > Solaris choice was to keep /bin/sh as the Bourne shell for > backward compatibility (as changing it for a POSIX shell > introduces a slight chance of breaking some existing scripts > as there are a few corner-case areas where the POSIX shells > are not backward compatible with the Bourne shell), and make > /bin a non standard place. How to get a conformant environment > (typically one where /usr/xpg4/bin/sh is before /bin) is > described in standards(5). The default one is not, which makes > Solaris a pain when porting scripts. > > HPUX (10.10 and newer at least): > /usr/bin/sh (and /bin/sh if there's a symlink /bin -> > usr/bin): a POSIX compliant shell (based on ksh88) > > /usr/old/bin/sh: the Bourne shell (though I think nowadays, > it's part of an optional package). > > Tru64: > /bin/sh can behave either as a Bourne shell or a POSIX shell > (ksh88) depending on the environment
How does it decide ? argv[0] ? isatty (STDIN_FILENO) ? > most Linux based systems and most other Unices: > /bin/sh is a POSIX compliant shell (bash generally for Linux) > and there's no Bourne shell (either there has never been or it > has been removed/replaced by a POSIX shell). Two other Unixen I know of that have a non-POSIX sh are SCO Open Server and UnixWare. I'm not sure they even provide a POSIX-compliant alternative like Solaris does. On the other hand, their utilities (awk, grep, sed et al.) seem to be POSIX-compliant, at least to the extent that I've always managed. Unlike Solaris where I've often had to use the ones in /usr/xpg4/bin. Many people assume "standard" equates "portable". As far as shell programming is concerned, the safest way to get portability is to ignore the standard and code for the Bourne shell. -- André Majorel <URL:http://www.teaser.fr/~amajorel/> "After 15 minutes, I wanted to marry her. After a half hour, I completely gave up the idea of snatching her purse." -- _Take the Money and Run_ -- http://mail.python.org/mailman/listinfo/python-list