[techtalk] need help: customizing bash behavior

Jonathan M. Katz jmkatz-72 at worldnet.att.net
Sun Feb 11 19:26:47 EST 2001


I'm a Linux newbie and I've been systematically reading the
O'Reilly book "Learning the bash Shell" by C. Newham, et. al.
(this is not a plug). I run RH 6.2, with the old (2.2) kernel, but I
have manually upgraded the shell to bash version 2.04.

I'm up to chapter three, which deals with customizing the shell's
behavior, including the use of environment settings and options
in the (global) bashrc and profile files, and I'm having some
trouble understanding how to implement certain settings of the
shell.

I was able to set the FCEDIT variable within profile, but all my
attempts to set the HISTIGNORE variable in that same file have
failed. I have also been unable to make "set -o ignoreeof" "stick"
when located in profile.... yet both the HISTIGNORE and
ignoreeof settings are perfectly happy in bashrc, which, from
my inspection of the comments in profile and bashrc, seems
like the "wrong place" for them to be. Am I making sense?

Anyhow, with the current setup, I get the results I want, but
it seems messy and a bit arbitrary, which probably means I've
missed some subtlety of proper configuration practices. BTW,
although I like Newham's book, there are some gaps in the
explanation of setting environment variables that are deppening
my current confusion.

I've included the two current versions of the files /etc/bashrc
and /etc/profile as inline text below... my additions to the
original articles are marked with #### and are as follows:

in bashrc: added lines 6-16; lines 12-16 appear (to me) to
be in the "wrong file", since they deal with the environment
and are not aliases or function definitions... but this is what
works for now!

in profile: added lines 22-24; tried inserting lines 12-16 from
bashrc at line 25 but to no avail.

Thanks in advance to anyone who can help out!
jkatz

::::: profile :::::
# /etc/profile

# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc

PATH="$PATH:/usr/X11R6/bin"

ulimit -c 1000000
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
         umask 002
else
         umask 022
fi

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

# System environment settings added by jkatz 11-Feb-2001
FCEDIT="/usr/bin/emacs" ####

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
         INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
         if [ -x $i ]; then
                 . $i
         fi
done

unset i

::::: bashrc :::::
# /etc/bashrc

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

# System aliases added by jkatz 11-Feb-2001
alias la='ls -la'               ####
alias md='mkdir'                        ####
alias rd='rmdir'                        ####
alias ro='rm *~; rm .*~'        ####

# System options added by jkatz 11-Feb-2001
set -o ignoreeof                        ####

HISTIGNORE="&"                  ####

# are we an interactive shell?
if [ "$PS1" ]; then
     if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
         stty erase `tput kbs`
     fi
     case $TERM in
         xterm*)
             PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
             ;;
         *)
             ;;
     esac
     PS1="[\u@\h \W]\\$ "

     if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
         for i in /etc/profile.d/*.sh; do
             if [ -x $i ]; then
                 . $i
             fi
         done
     fi
fi






More information about the Techtalk mailing list