[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: terminating lines with accidental eof

From: Martin Wheatley
Subject: Re: terminating lines with accidental eof
Date: Wed, 05 Jul 2006 09:58:08 +0100
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.12) Gecko/20050928

Bob Proulx wrote:
Martin Wheatley wrote:

You also asked ...

Is there an example of
another command shell which handles this situation in a different and
possibly better way?

/bin/sh handles the situation correctly (in our opinion)

On my system /bin/sh is a symlink to /bin/bash and behaves similarly.
But on other systems it may be a symlink to other shells or may be a
native posix shell implementation.  Or on some systems trying to be
antiquated it may be a classic Bourne shell.  Many posix shell
implementations are based upon the AT&T ksh.  On the systems I tested
they all behaved like bash does here.


We ran the same test against ksh on our systems and it behaves as we would
expect (ie commands are only executed when the user hits enter and NOT executed 
when an I/O error
occurs on the input stream).

Our (Solaris) systems are shipped by the supplier with a classic bourne shell
which is what our developers are required to use for production scripts 
however, for
interactive use we all prefer bash for its more powerful, user friendly, 

Linking /bin/sh to /bin/bash does NOT maintain the bourne shell API.

For example,

Tradition using a traditional bourne shell ...

xn-sysadm-4 $ sh
xn-sysadm-4 $ PWD=fred
xn-sysadm-4 $ cd /
xn-sysadm-4 $ echo $PWD
xn-sysadm-4 $

But with bash linked as "sh"...

xn-CDO-2 $ cd /tmp
xn-CDO-2 $ ln -s /bin/bash ./sh
xn-CDO-2 $ ./sh
xn-CDO-2 $ PWD=fred
xn-CDO-2 $ cd /
xn-CDO-2 $ echo $PWD

Note the difference in output from the echo.

And there are other similar cases (notable the fact the the 'cd' builtin has 
options [-L|-P] in
bash but not in /bin/sh) - which makes it very hard to write a shell script 
that is going to be
executed either in a traditional /bin/sh or a /bin/sh that is a (sym-)link to 

Thus we consider that having /bin/sh as a (sym-)link to /bin/bash to be a bad 
idea or that the implementation is wrong.


| Martin Wheatley        | Voice : +44-(0)1235 464784              |
| CODAS                  | Mobile: +44-(0)468  894818              |
| UKAEA, Culham Division | FAX   : +44-(0)1235 464404              |
| Culham Science Centre  |                                         |
| Abingdon, Oxfordshire  |                                         |
| OX14 3DB               | E-mail: address@hidden          |
| United Kingdom         |     or: address@hidden    |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]