From 722b1261607fb28328c708d45a39e8786139aa70 Mon Sep 17 00:00:00 2001 From: Ondřej Vašík Date: Nov 26 2008 12:51:38 +0000 Subject: Process profile.d scripts non-interactive shell, fix user in csh prompt - bashrc: do process profile.d scripts in noninteractive shells, do not show stderr and stdout output - csh.cshrc: do process profile.d scripts in noninteractive shells, do not show stderr and stdout output, fix displaying user in tcsh prompt - csh.login: do process profile.d scripts in noninteractive shells, do not show stderr and stdout output - profile : do not show error message for missing hostname, do process profile.d scripts in noninteractive shells, do not show stderr and stdout output, export PATH after profile.d scripts processing --- diff --git a/bashrc b/bashrc index 4d82f3a..d8ba3c3 100644 --- a/bashrc +++ b/bashrc @@ -49,14 +49,18 @@ if ! shopt -q login_shell ; then # We're not a login shell fi } - # Only run profile.d scripts if we are no login shell and interactive - if [ "$PS1" ]; then - for i in /etc/profile.d/*.sh; do - if [ -r "$i" ]; then + # Only display echos from profile.d scripts if we are no login shell + # and interactive - otherwise just process them to set envvars + for i in /etc/profile.d/*.sh; do + if [ -r "$i" ]; then + if [ "$PS1" ]; then . $i + else + . $i &>/dev/null fi - done - fi + fi + done + unset i unset pathmunge fi diff --git a/csh.cshrc b/csh.cshrc index 2b2cede..a69c345 100644 --- a/csh.cshrc +++ b/csh.cshrc @@ -13,7 +13,7 @@ endif if ($?prompt) then if ($?tcsh) then set promptchars='$#' - set prompt='[%u@%m %c]%# ' + set prompt='[%n@%m %c]%# ' # make completion work better by default set autolist else @@ -54,15 +54,17 @@ limit coredumpsize 0 # Check if we aren't a loginshell and do stuff if we aren't if (! $?loginsh) then - if ($?prompt) then - if ( -d /etc/profile.d ) then - set nonomatch - foreach i ( /etc/profile.d/*.csh ) - if ( -r $i ) then - source $i - endif - end - unset i nonomatch - endif - endif + if ( -d /etc/profile.d ) then + set nonomatch + foreach i ( /etc/profile.d/*.csh ) + if ( -r $i ) then + if ($?prompt) then + source $i + else + source $i >&/dev/null + endif + endif + end + unset i nonomatch + endif endif diff --git a/csh.login b/csh.login index 3e98bb3..c49161e 100644 --- a/csh.login +++ b/csh.login @@ -21,14 +21,16 @@ if ( ! -f $HOME/.inputrc ) then setenv INPUTRC /etc/inputrc endif -if ($?prompt) then - if ( -d /etc/profile.d ) then - set nonomatch - foreach i ( /etc/profile.d/*.csh ) - if ( -r $i ) then - source $i - endif - end - unset i nonomatch - endif +if ( -d /etc/profile.d ) then + set nonomatch + foreach i ( /etc/profile.d/*.csh ) + if ( -r $i ) then + if ($?prompt) then + source $i + else + source $i >& /dev/null + endif + endif + end + unset i nonomatch endif diff --git a/profile b/profile index 94a51d7..ea1ff91 100644 --- a/profile +++ b/profile @@ -39,7 +39,7 @@ if [ -x /usr/bin/id ]; then MAIL="/var/spool/mail/$USER" fi -HOSTNAME=`/bin/hostname` +HOSTNAME=`/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then @@ -50,9 +50,15 @@ export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then - . $i + if [ "$PS1" ]; then + . $i + else + . $i &>/dev/null + fi fi done +export PATH + unset i unset pathmunge