Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 4738 - .bashrc and profile
Summary: .bashrc and profile
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-09 06:04 UTC by ozymandias
Modified: 2002-08-07 13:03 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ozymandias 2002-07-09 06:04:47 UTC
Actually there are two things but they are higly related 
in /etc/skel/.bashrc it says that is must not generate output due to not 
interactive bash startups that read that file. This is not true, the man page 
states that .bashrc is for "The individual per-interactive-shell startup file" 
and that is where it is used for. 
	So in order to give xterm a pretty promt, .bashrc needs to be usefull, 
because the default doesn't read /etc/profile and $HOME/.bash_profile. My 
.bashrc does a "source /etc/profile". This topic gets discussed a lot on the 
forum, so a better default would help. 
 
Which comes to my second bug (or recomendation) change the /etc/profile so that 
it gives an xterm a nice title bar, this is how I did it: 
 
# Copyright 1999-2002 Gentoo Technologies, Inc. 
# Distributed under the terms of the GNU General Public License, v2 or later 
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/profile,v 1.12 2002/05/12 
21:48:18 azarah Exp $ 
 
if [ -e "/etc/profile.env" ] 
then 
  source /etc/profile.env 
fi 
 
#077 would be more secure, but 022 is generally quite realistic 
umask 022 
 
if [ `/usr/bin/whoami` = 'root' ] 
then 
        if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ] 
        then 
                if [ "$TERM" = 'linux' ] 
                then 
                        export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ 
\[\033[00m\]' 
                else 
                        export PS1='\[\033]0;\u@\h:\w\007\]\[\033[01;31m\]\u@\h 
\[\033[01;34m\]\W \$ \[\033[00m\]' 
                fi 
        fi 
        export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${ROOTPATH}" 
else 
        if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ] 
        then 
                if [ "$TERM" = 'linux' ] 
                then 
                        export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ 
\[\033[00m\]' 
                else 
                         export 
PS1='\[\033]0;\u@\h:\w\007\]\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ 
\[\033[00m\]' 
                fi 
        fi 
        export PATH="/bin:/usr/bin:${PATH}" 
fi 
unset ROOTPATH 
export EDITOR="/usr/bin/vi" 
 
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then 
        export INPUTRC="/etc/inputrc" 
fi 
 
alias ls='ls --color' 
#### end of /etc/profile 
 
this way it checks what type of term it is, in case of "linux", (virtual 
terminal) it will only color the prompt, in all other cases (should be just in 
case of xterm eterm konsole etc, cause login in with ssh will probably use the 
prompt with title to, but I don't log in via ssh) it will put the prompt in the 
title bar as well. 
My profile is based on the latest profile from gentoo, from which I merged it 
with my original. 
 
greetz Ozy
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-07-09 13:45:21 UTC
--------------------------cut---------------------------------------------
       When  bash  is invoked as an interactive login shell, or as a
non-interactive shell with the --login option, it first reads and exe-
       cutes commands from the file  /etc/profile,  if  that  file  exists.  
After  reading  that  file,  it  looks  for  ~/.bash_profile,
       ~/.bash_login,  and  ~/.profile, in that order, and reads and executes
commands from the first one that exists and is readable.  The
       --noprofile option may be used when the shell is started to inhibit this
behavior.

       When a login shell exits, bash reads and executes commands from the file
~/.bash_logout, if it exists.

       When an interactive shell that is not a login shell is started, bash
reads and  executes  commands  from  ~/.bashrc,  if  that  file
       exists.   This  may  be inhibited by using the --norc option.  The
--rcfile file option will force bash to read and execute commands
       from file instead of ~/.bashrc.
---------------------------cut-------------------------------------------

Which means that if you want /etc/profile sourced, you start the shell
as a login shell.  In all other cases, .bashrc will be sourced (with the
default bash behaviour if started as interactive shell, and not login).

Then, by default the .bash_profile (installed from /etc/skel) have the
following:

----------------cut--------------------------------------
#This file is sourced by bash when you log in interactively.
[ -f ~/.bashrc ] && . ~/.bashrc
----------------cut--------------------------------------

Which is pretty much like many other distro's do.  This will thus make
the message in .bashrc true, as with our default setup, .bashrc will
always be sourced.  This tends to make things a bit more consistent,
as aliases/whatever in .bashrc will always be available.

Sourcing /etc/profile in .bashrc now as well, will make it be sourced
twice with a login shell.

The only real issue with /etc/profile, is people not setting thier xterms
to use login shells.  If you really want to source /etc/profile in
.bashrc, sure, just add it.  I have never.  Most people I know dont.  I 
really cannot see what this whole issue is with adding more and more
stuff to the defaults that comes with the distro.  Your startup files
is something that is supposed to be personal ... everybody will have
it to suit his needs, while whatever that is in place after distro install,
should just be sane, basic defaults.

As for the second issue, its already been added to CVS (and not /etc/profile,
as this is too intrusive, but rather .bashrc).  See bug #4232.