bug-bash
[Top][All Lists]
Advanced

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

Re: terminating lines with accidental eof


From: Eric Blake
Subject: Re: terminating lines with accidental eof
Date: Wed, 05 Jul 2006 06:25:50 -0600
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Martin Wheatley on 7/5/2006 2:58 AM:
> 
> 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
> fred
> xn-sysadm-4 $

That is a bug in traditional bourne shell, and you should not rely on it.
 POSIX does not permit manually setting PWD to anything other than an
actual absolute name, and even allows implementations to reject your
attempt to set it to the relative name "fred" as though you had been
trying to set a read-only variable.

> 
> 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
> /

POSIX requires this behavior, whether bash is emulating sh (in which case,
it is really trying to be POSIX compliant, rather than compatible to old
broken bourne sh), or using full extensions.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEq6/N84KuGfSFAYARAstBAKCJhd13/iDDJOzDCz74rVxkwz8UwACeNpKI
SJ5ZMCabrMnrSH34kyBtx9U=
=ozhB
-----END PGP SIGNATURE-----




reply via email to

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