[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Standard .bashrc needs a minor fix
From: |
Chuck Remes |
Subject: |
Standard .bashrc needs a minor fix |
Date: |
Thu, 06 May 2010 09:30:20 -0500 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -march=x86-64
-mtune=generic -O2 -pipe
uname output: Linux box1 2.6.33-ARCH #1 SMP PREEMPT Sun Apr 4 10:27:30 CEST
2010 x86_64 Intel(R) Xeon(R) CPU X5355 @ 2.66GHz GenuineIntel GNU/Linux
Machine Type: x86_64-unknown-linux-gnu
Bash Version: 4.1
Patch Level: 5
Release Status: release
Description:
The standard .bashrc contains a line of code that precludes certain scripts
from executing. It has to do with
the logic for checking if the session is interactive.
e.g.
[ -z "$PS1" ] && return
Usually a few other lines are included afterward to, for example, alias 'ls'
and to set PS1 to a new value.
Some scripts like rvm (rvm.beginrescueend.com) need to run at the tail end of
the login process to tack on more data
to PATH or set other environment variables (think of it as a post-login hook).
These kinds of scripts fail to execute
with the code above.
Repeat-By:
Login.
Fix:
Here's an alternate method to perform the interactive session check, which
accomplishes the same effect in a much safer manner.
# Check for an interactive session
if [[ ! -z "$PS1" ]] ; then
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
fi
This allows scripts at the end of the .bashrc to be sourced/executed under all
normal conditions, as well as sourcing of .bashrc from scripts.
- Standard .bashrc needs a minor fix,
Chuck Remes <=
- Message not available