Bug 23587 - OSTYPE (etc) is clobbered by BASH2
OSTYPE (etc) is clobbered by BASH2
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-01-08 11:56 EST by Aric
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-01-08 12:09:59 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Aric 2001-01-08 11:56:32 EST
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
vxworks-target
% /bin/sh -c 'echo $OSTYPE'
linux-gnu
% (/bin/sh -c 'echo $OSTYPE')
linux-gnu

Here is the same thing run on Solaris:
$ OSTYPE=vxworks-target
$ export OSTYPE
$ echo $OSTYPE
vxworks-target
$ /bin/sh -c 'echo $OSTYPE'
vxworks-target
$ (/bin/sh -c 'echo $OSTYPE')
vxworks-target
Comment 1 Bernhard Rosenkraenzer 2001-01-10 18:11:03 EST
This is the intended behavior according to the bash manpage and probably POSIX.
If you don't like it, talk to bug-bash@gnu.org - we're not changing it in our
package and breaking compatibility with everyone else.
Comment 2 Aric 2001-01-11 09:04:55 EST
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?

Note You need to log in before you can comment on or make changes to this bug.