From 8830b2fa1e5bde0ea8e654007054aa3a95b882fb Mon Sep 17 00:00:00 2001 From: Chris Greenshields Date: Tue, 7 Sep 2021 17:10:13 +0100 Subject: [PATCH] etc/bashrc: removed sourcing of additional files passed as arguments to the original sourced file. Caused an infinite loop if original source command is called within a function, e.g. sourceFile() { . $1 } --- etc/bashrc | 6 +++--- etc/config.sh/functions | 13 ++----------- etc/cshrc | 12 ++++-------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 13a70aa167..99aa258f56 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -158,10 +158,10 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Add in preset user or site preferences: _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` -# Evaluate command-line parameters and record settings for later -# these can be used to set/unset values, or specify alternative pref files +# Evaluate command-line parameters of the form "param=keyword" or unset +# parameters with "param=" export FOAM_SETTINGS="$@" -_foamEval $@ +_foamParams $@ # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/etc/config.sh/functions b/etc/config.sh/functions index 05ec338223..8a7ef9d720 100644 --- a/etc/config.sh/functions +++ b/etc/config.sh/functions @@ -48,7 +48,7 @@ then } # Evaluate command-line parameters - _foamEval() + _foamParams() { while [ $# -gt 0 ] do @@ -67,15 +67,6 @@ then [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1" 1>&2 eval "export $1" ;; - *) - # Filename: source it - if [ -f "$1" ] - then - _foamSource "$1" - else - _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"` - fi - ;; esac shift done @@ -117,6 +108,6 @@ else # ~~~~~~~~~~~~~~~~~~~~ unset WM_BASH_FUNCTIONS unset _foamAddPath _foamAddLib _foamAddMan - unset _foamSource _foamEval + unset _foamSource _foamParams fi diff --git a/etc/cshrc b/etc/cshrc index a497e28d6e..d86cdb02ee 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -151,8 +151,8 @@ alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* # Add in preset user or site preferences: _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh` -# Evaluate command-line parameters and record settings for later -# these can be used to set/unset values, or specify alternative pref files +# Evaluate command-line parameters of the form "param=keyword" or unset +# parameters with "param=" setenv FOAM_SETTINGS "${*}" while ( $#argv > 0 ) switch ($argv[1]) @@ -171,12 +171,8 @@ while ( $#argv > 0 ) eval "setenv $argv[1]:s/=/ /" breaksw default: - # filename: source it - if ( -f "$1" ) then - _foamSource "$1" - else - _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"` - endif + # ignore non-parameter arguments, e.g. filenames + break breaksw endsw shift