Red Hat Bugzilla – Bug 23587
OSTYPE (etc) is clobbered by BASH2
Last modified: 2008-05-01 11:37:59 EDT
We have a system-wide standard for the environment variable OSTYPE that has
been in place for years. Whenever bash is run, it clobbers this variable.
On my platform, it always sets it to linux-gnu. The older versions of Bash
set this to "linux" so this problem has not popped up until now. This
messes up Makefiles because make runs subshells all the time, and the
OSTYPE is being clobbered all the time.
First, I can understand wanting to set this variable, but bash should not
set the variable if it is already set. This is a design decision with which
some may disagree, but you cannot disagree with the second problem here:
Second, when bash is run as sh (e.g., /bin/sh) it is supposed to behave as
much as possible like the old Bourne Shell, yet bash2 still clobbers OSTYPE.
It does the same thing, BTW, with MACHTYPE, etc.
Here's how to reproduce the problem:
% help | grep version
GNU bash, version 2.04.11(1)-release (i386-redhat-linux-gnu)
% export OSTYPE=vxworks-target
% echo $OSTYPE
% /bin/sh -c 'echo $OSTYPE'
% (/bin/sh -c 'echo $OSTYPE')
Here is the same thing run on Solaris:
$ export OSTYPE
$ echo $OSTYPE
$ /bin/sh -c 'echo $OSTYPE'
$ (/bin/sh -c 'echo $OSTYPE')
This is the intended behavior according to the bash manpage and probably POSIX.
If you don't like it, talk to email@example.com - we're not changing it in our
package and breaking compatibility with everyone else.
First, this is definitely not the intended behavior according to the bash
manpage. I quote it here: "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." The behavior I describe is not
even close to the "historical versions of sh". "probably POSIX" is not good
enough. How about checking into it?
Second, I don't expect you to break compatibility with everyone else, but other
linux distributions forward bug reports like this to the appropriate people. I
have seen many debian bug reports on the Vim and mutt email lists. With lazy
product support like this, is it any wonder that your stock price is where it is?