Bug 678 - /etc/bashrc sets PS1 at inappropriate times
/etc/bashrc sets PS1 at inappropriate times
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
5.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-01-03 17:06 EST by Ted Powell
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: 1999-01-04 19:25:13 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Ted Powell 1999-01-03 17:06:12 EST
The version of /etc/bashrc contained in bash-1.14.7-13 is as
follows:

  # /etc/bashrc

  # System wide functions and aliases
  # Environment stuff goes in /etc/profile

  # For some unknown reason bash refuses to inherit
  # PS1 in some circumstances that I can't figure out.
  # Putting PS1 here ensures that it gets loaded every time.
  PS1="[\u@\h \W]\\$ "

  alias which="type -path"

RTFM.

Searching the BASH(1) man page for the string "PS1" gets a
hit in the INVOCATION section, which reads in part:

"PS1 is set ... if bash is interactive, allowing a shell
script or a startup file to test this state."

Setting PS1 unconditionally, as is done by the current
/etc/bashrc, breaks this facility.

If it is desired to set PS1, when appropriate, to a specific
string, this can be done with:

  # PS1 is only supposed to be set for an interactive shell.
  # Since this is the only easy test for an
interactive        # shell, it should not be tampered with.
  #
  if [ x${PS1+set} = xset ]; then
      # interactive
      PS1="[\u@\h \W]\\$ "
  fi

Three reasons why a user should be able to use a simple test
(namely, seeing whether PS1 is set) for whether the current
shell is interactive:

3. ``stty </dev/tty erase ^H'' gets an annoying complaint
if    the shell is not interactive.

2. Operations such as updating the window title bar
generate    unacceptable overhead if done in a long-running
script.

1. BASH(1) SAYS YOU CAN DO IT.
Comment 1 David Lawrence 1999-01-04 19:25:59 EST
Thank you for the suggestion. It has been noted and will be considered
for future releases of Red Hat.

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