* Don't source /etc/profile in interactive non-login shells, unless it

wasn't sourced in a parent shell (as determined by the environment
  variable __ETC_PROFILE_DONE).  This prevents overriden values of
  environment variables such as $PATH from being clobbered in
  subshells.
* Move all aliases to /etc/bashrc (since those are for interactive
  use).

svn path=/nixos/trunk/; revision=33246
This commit is contained in:
Eelco Dolstra 2012-03-19 02:35:17 +00:00
parent b1fd71038e
commit bcbe2dce4c
2 changed files with 51 additions and 45 deletions

View File

@ -1,40 +1,48 @@
# /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
if [ \( -n "${SYSTEM_ETC_BASHRC_HAS_BEEN_SOURCED:-}" \) -o \( -n "${NOSYSBASHRC:-}" \) ]; then
return
else
SYSTEM_ETC_BASHRC_HAS_BEEN_SOURCED="1"
# This file is read for interactive non-login shells.
# Only execute this file once per shell.
if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
__ETC_BASHRC_SOURCED=1
# If the profile was not loaded in a parent process, source it. But
# otherwise don't do it because we don't want to clobber overriden
# values of $PATH, etc.
if [ -z "$__ETC_PROFILE_DONE" ]; then
. /etc/profile
fi
. /etc/profile
# We are not always an interactive shell.
if [ -z "$PS1" ]; then return; fi
# If we are an interactive shell ...
if [ -n "$PS1" ]; then
# Check the window size after every command.
shopt -s checkwinsize
# Check the window size after every command.
shopt -s checkwinsize
# Provide a nice prompt.
PROMPT_COLOR="1;31m"
let $UID && PROMPT_COLOR="1;32m"
PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
if test "$TERM" = "xterm"; then
PS1="\[\033]2;\h:\u:\w\007\]$PS1"
fi
# Provide a nice prompt.
PROMPT_COLOR="1;31m"
let $UID && PROMPT_COLOR="1;32m"
PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] "
if test "$TERM" = "xterm"; then
PS1="\[\033]2;\h:\u:\w\007\]$PS1"
fi
# Check whether we're running a version of Bash that has support for
# programmable completion. If we do, and if the current user has
# installed the package 'bash-completion' in her $HOME/.nix-profile,
# then completion is enabled automatically.
if [ -f "$HOME/.nix-profile/etc/bash_completion" ]; then
if [ -d "$HOME/.nix-profile/etc/bash_completion.d" ]; then
if shopt -q progcomp &>/dev/null; then
BASH_COMPLETION_DIR="$HOME/.nix-profile/etc/bash_completion.d"
BASH_COMPLETION="$HOME/.nix-profile/etc/bash_completion"
. "$BASH_COMPLETION"
fi
# Check whether we're running a version of Bash that has support for
# programmable completion. If we do, and if the current user has
# installed the package 'bash-completion' in her $HOME/.nix-profile,
# then completion is enabled automatically.
if [ -f "$HOME/.nix-profile/etc/bash_completion" ]; then
if [ -d "$HOME/.nix-profile/etc/bash_completion.d" ]; then
if shopt -q progcomp &>/dev/null; then
BASH_COMPLETION_DIR="$HOME/.nix-profile/etc/bash_completion.d"
BASH_COMPLETION="$HOME/.nix-profile/etc/bash_completion"
. "$BASH_COMPLETION"
fi
fi
# Some aliases.
alias which="type -P"
fi
# Some aliases.
alias ls="ls --color=tty"
alias ll="ls -l"
alias l="ls -alh"
alias which="type -P"

View File

@ -1,10 +1,15 @@
# /etc/profile: DO NOT EDIT -- this file has been generated automatically.
if [ -n "${SYSTEM_ETC_PROFILE_HAS_BEEN_SOURCED:-}" ]; then
return
else
SYSTEM_ETC_PROFILE_HAS_BEEN_SOURCED="1"
fi
# This file is read for (interactive) login shells. Any
# initialisation specific to interactive shells should be put in
# /etc/bashrc, which is sourced from here.
# Only execute this file once per shell.
if [ -n "$__ETC_PROFILE_SOURCED" ]; then return; fi
__ETC_PROFILE_SOURCED=1
# Prevent this file from being sourced by interactive non-login child shells.
export __ETC_PROFILE_DONE=1
# Initialise a bunch of environment variables.
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib:/var/run/opengl-driver-32/lib # !!! only set if needed
@ -33,9 +38,7 @@ for i in $NIX_PROFILES; do # !!! reverse
export TERMINFO_DIRS=$i/share/terminfo${TERMINFO_DIRS:+:}$TERMINFO_DIRS
export TERM=$TERM
# "lib/site_perl" is for backwards compatibility with packages
# from Nixpkgs <= 0.12.
export PERL5LIB="$i/lib/perl5/site_perl:$i/lib/site_perl${PERL5LIB:+:}$PERL5LIB"
export PERL5LIB="$i/lib/perl5/site_perl${PERL5LIB:+:}$PERL5LIB"
# ALSA plugins
export ALSA_PLUGIN_DIRS="$i/lib/alsa-lib${ALSA_PLUGIN_DIRS:+:}$ALSA_PLUGIN_DIRS"
@ -51,7 +54,7 @@ for i in $NIX_PROFILES; do # !!! reverse
export XDG_CONFIG_DIRS=$i/etc/xdg${XDG_CONFIG_DIRS:+:}$XDG_CONFIG_DIRS
export XDG_DATA_DIRS=$i/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS
# mozilla plugins
# Mozilla plugins.
export MOZ_PLUGIN_PATH=$i/lib/mozilla/plugins${MOZ_PLUGIN_PATH:+:}$MOZ_PLUGIN_PATH
done
@ -62,7 +65,7 @@ export ASPELL_CONF="dict-dir $HOME/.nix-profile/lib/aspell"
export PATH=@wrapperDir@:$PATH
# ~/bin if it exists overrides other bin directories.
if test -d $HOME/bin; then
if [ -d $HOME/bin ]; then
export PATH=$HOME/bin:$PATH
fi
@ -102,11 +105,6 @@ fi
@shellInit@
# Some aliases.
alias ls="ls --color=tty"
alias ll="ls -l"
alias l="ls -alh"
# Read system-wide modifications.
if test -f /etc/profile.local; then
. /etc/profile.local