[X-Unix] awk

Stroller MacMonster at myrealbox.com
Thu Jan 8 01:33:16 PST 2004


On Jan 8, 2004, at 7:37 am, Eugene Lee wrote:

> On Wed, Jan 07, 2004 at 08:46:38PM +0000, Stroller wrote:
> : On Jan 7, 2004, at 5:41 pm, Eugene Lee wrote:
> : >:
> : >: There are annoying differences between "standard Unix" versions 
> of the
> : >: utilities and their GNU counterparts. Usually they Unix versions 
> are
> : >: compatible with the GNU versions, but the GNU versions are not
> : >: compatible with the Unix versions.   ... Just as scripts written 
> for
> : >: /bin/sh will work in /bin/ksh or /bin/bash ... scripts written for
> : >: either ksh or zsh will not run in sh.
> : >
> : >Too bad /bin/bash is the same as /bin/sh.  :-)
> :
> : Excuse me if I missed the joke, but from `man bash`:
> :
> : DESCRIPTION
> :        Bash  is  an  sh-compatible  command language interpreter 
> that executes
> :        commands read from the standard input or from a file.  Bash 
> also incor-
> :        porates useful features from the Korn and C shells (ksh and 
> csh).
>
> Well, bash also has useful features from ksh and csh, that means that
> these features are not available in old sh.  Therefore, any bash script
> that uses any of these new features is not guaranteed to work on a
> machine that has the original sh and not bash.  This is just another
> example of a GNU version of a tool (i.e. bash) is not compatible with
> the Unix version (i.e. sh).

I think you missed the part I quoted in which I said:

INVOCATION
...
        If  bash  is  invoked  with  the name sh, it tries to mimic the 
startup
        behavior of historical versions of sh as  closely  as  possible, 
  while
        conforming  to the POSIX standard as well.

So if one is writing a script which one wishes to be cross-platform, 
one simply writes it with the header "#!/bin/sh" and any of Bash's 
advanced features will be ignored; one will only be able to use sh 
syntax in that script.

Stroller.



More information about the X-Unix mailing list