Which shell?

Which shell?

Post by Sven Maschec » Thu, 08 Dec 2005 03:51:40




>> [bash(1):]
>> 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.

> Admittedly this leaves confusion in areas where Bourne and POSIX
> disagree.

> [...]

> it's not well implemented; bash isn't very
> Bourne compatible even when run as "sh".

There are two misunderstandings:

1. what exactly does "bourne compatible" mean?

   It's about the basic language.
   It's not about specifically traditional features.
   Yes, _all_ bourne compatible shells (korn shell included)
   are incompatible here.  But this is usually considered a
   feature, because the old behaviour is flawed in some way.

   See <http://www.in-ulm.de/~mascheck/bourne/common.html>
   for a list of most traditional-only features.

2. what does "mimic sh" in the above mean

   The most prominent exmaple of a traditional-only feature
   is ^ being an alias for |.  Certainly, no modern shell
   should try to mimic this.

   Except for the startup behaviour (profiles), bash doesn't
   mimic traditional features.  If you do read "info bashref"
   (it's not in the man page), you'll see that only POSIX is
   relevant here.

Quote:> Right now bash is neither POSIX nor Bourne compatible

So please name name concrete, relevant POSIX incompatibilities.
But this is not related to Solaris anymore:

xpost+fup2 comp.unix.shell

 
 
 

Which shell?

Post by Sven Maschec » Sun, 11 Dec 2005 09:28:40



>> [ differences between bourne and korn "sh -n" ]
> it's all right if sh can report some problems.  But does it report
> the same ones?

Basically yes, although modern shells certainly give more
differentiated error messages (e.g.: "end of file unexpected"
vs a concrete "XY unmatched").

All differences between the shells surely would be neglectable
in comparison to a real "lint" :)

Interestingly, both shells "unexpectedly" fail to see the following
"syntax" error ("macro processors" having a hard time?), while zsh
can catch it:

$ shell -nc 'test 1 === 2'

[we should be discussing this in a shell group]

 
 
 

Which shell?

Post by Thomas Dicke » Sun, 11 Dec 2005 09:53:05



Quote:> All differences between the shells surely would be neglectable
> in comparison to a real "lint" :)

A real lint should flag portability problems.  Though I recall being somewhat
disappointed with lint's portability checks, I did agree with the general
intention.

Quote:> Interestingly, both shells "unexpectedly" fail to see the following
> "syntax" error ("macro processors" having a hard time?), while zsh
> can catch it:
> $ shell -nc 'test 1 === 2'

probably not macro processors, but a handcoded parser.

What I see here

        http://www.veryComputer.com/

looks that way.  I don't see the ksh code there however (would be interesting
to contrast them).

--
Thomas E.*ey
http://www.veryComputer.com/
ftp://invisible-island.net

 
 
 

Which shell?

Post by Joerg Schilli » Sun, 11 Dec 2005 20:58:22




Quote:>Interestingly, both shells "unexpectedly" fail to see the following
>"syntax" error ("macro processors" having a hard time?), while zsh
>can catch it:

>$ shell -nc 'test 1 === 2'

There is no _shell_ syntax error in this command line.
Although test is a shell builtin, it is acting like a command
that would only detect the _test_ syntax error in case it is run.

Quote:>[we should be discussing this in a shell group]

later ;-)

--



URL:  http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

 
 
 

Which shell?

Post by Stephane CHAZELA » Mon, 12 Dec 2005 02:52:59


2005-12-10, 01:28(+01), Sven Mascheck:

>>> [ differences between bourne and korn "sh -n" ]

>> it's all right if sh can report some problems.  But does it report
>> the same ones?

> Basically yes, although modern shells certainly give more
> differentiated error messages (e.g.: "end of file unexpected"
> vs a concrete "XY unmatched").

> All differences between the shells surely would be neglectable
> in comparison to a real "lint" :)

> Interestingly, both shells "unexpectedly" fail to see the following
> "syntax" error ("macro processors" having a hard time?), while zsh
> can catch it:

> $ shell -nc 'test 1 === 2'

[...]

It's different with zsh because "=whatever" is special in zsh (a
globbing operator) and because unresolved globbing is an error
as well (while other shells fall back on leaving the pattern
untouched (which is a bug to my mind))

=foo returns the path to foo after a look up in $PATH.

$  ls -ld -- =ls
-rwxr-xr-x 1 root root 76872 Nov 16 13:17 /bin/ls*

In other shells, test 1 === 2 is not a syntax error, it's a
valid simple command line.

[[ 1 === 2 ]] would be because what's inside [[ ]] is part of
the shell syntax, not of a particular utility argument syntax.

Typically:

test $a === $b

could be syntactically correct, even for test if for instance $a
was "-n" and $b was "-o -n 1".

--
Stphane

 
 
 

Which shell?

Post by Christian Schneide » Mon, 12 Dec 2005 03:22:14


Hi Stephane,


> 2005-12-10, 01:28(+01), Sven Mascheck:

>>>> [ differences between bourne and korn "sh -n" ]
[...]
> =foo returns the path to foo after a look up in $PATH.

> $  ls -ld -- =ls
> -rwxr-xr-x 1 root root 76872 Nov 16 13:17 /bin/ls*

[...]

Why `--'? As far as i know it's not really needed.
#v+
painless% ls -ld -- =ls
-rwxr-xr-x  1 root root 62980 Aug  7 01:36 /bin/ls
painless% ls -ld =ls
-rwxr-xr-x  1 root root 62980 Aug  7 01:36 /bin/ls
painless%
#v-
Correct me if i'm wrong :)
--
NOTICE: Reading this message will increase the amount
of disorder in the universe. Although no liability is
implied herein, the reader is warned that this process
will ultimately lead to the heat-death of the universe.

 
 
 

Which shell?

Post by Stephane CHAZELA » Mon, 12 Dec 2005 03:32:22


2005-12-10, 19:22(+01), Christian Schneider:
[...]

Quote:>> $  ls -ld -- =ls
>> -rwxr-xr-x 1 root root 76872 Nov 16 13:17 /bin/ls*
> [...]

> Why `--'? As far as i know it's not really needed.
> #v+
> painless% ls -ld -- =ls
> -rwxr-xr-x  1 root root 62980 Aug  7 01:36 /bin/ls
> painless% ls -ld =ls
> -rwxr-xr-x  1 root root 62980 Aug  7 01:36 /bin/ls
> painless%
> #v-
> Correct me if i'm wrong :)

Depends whether you know the value of $PATH in advance or not.

~$ mkdir /tmp/-e
~$ ln -s /bin/ls /tmp/-e
~$ cd /tmp
/tmp$ path=(-e $path)
/tmp$ ls -ld =ls
ls: invalid option -- e
Try `ls --help' for more information.

For any "variable/unknown" value, I use "--" to mark the end of
options. In any case, it can't harm.

--
Stphane

 
 
 

Which shell?

Post by bsh » Thu, 22 Dec 2005 12:32:16




> > [ differences between bourne and korn "sh -n" ]
> > > [ lint(1) for shell ... ]

I just wanted to interject, that the -n option to
ksh(1) version 1999 or newer is greatly improved
to function as a simple lint(1). Portability hints
and caveats are emitted.

=Brian

 
 
 

Which shell?

Post by bsh » Tue, 27 Dec 2005 14:11:29


Did I actually say "1999 or newer"?! I meant 1993 or
newer; that is, the latest distribution of kornshell.

=Brian

 
 
 

1. Bourne Shell compatible shells (was: Request: which shells)


Me too :-)

I also had some problems with smail and make depend. Don't remember how I
fixed them.

I also detected two other problems with bash 1.12:

 - it wouldn't run the Configure script of trn 3.0 (beta). This will be
   fixed in bash 1.13, but the Configure script has already changed so that
   it works with bash 1.12 too.

 - it does something wrong with passing $* from other shell scripts which are
   included by the `.' command. I detected this when INN 1.4 rejected all
   newgroup messages.

The pdksh I have (4.7) is absolutely unuseable for running Configure
scripts. Try the following script with pdksh 4.7 with two or more parameters:

        #!/bin/ksh

Zsh gives also problems with Configure scripts.

I use tcsh as interactive shell and bash as /bin/sh substitute because bash
is the more-or-less Bourne shell compatible shell which runs most of the
(Configure) scripts I have.  Running Configure scripts (sometimes >100Kb) is
a real good test for testing /bin/sh compatibility of shells.

Arjan

--


2. minicom & cron

3. shells shells shells

4. Help with resources monitoring

5. handling SIGINT in shell scripts when executing another shell script.

6. Disk information

7. UNIX shell differences and how to change your shell (Monthly Posting)

8. HELP! Sendmail w/o DNS

9. killing a shell that has a running child shell

10. Changing from the Bourne shell to C-shell

11. UNIX shell differences and how to change your shell (Monthly Posting)

12. Trying to run nohup from Korn shell but getting Bourne shell errors