From 957d8dc38d3cf583395a9bca9ce77a28895712d4 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 19 Jul 2018 16:57:38 +0200 Subject: [PATCH] CONFIG: force loading of shell functions (issue #944) - this avoids a situation when an aborted sourcing of the etc/bashrc file can leave WM_SHELL_FUNCTIONS defined, which causes all subsequent sourcing to fail. --- etc/bashrc | 1 + etc/config.sh/functions | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/etc/bashrc b/etc/bashrc index b1a4cc45db..1ddb55affc 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -135,6 +135,7 @@ fi export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Load shell functions +unset WM_SHELL_FUNCTIONS . $WM_PROJECT_DIR/etc/config.sh/functions # Overrides via diff --git a/etc/config.sh/functions b/etc/config.sh/functions index 0ff0ea3704..39afd27bd8 100644 --- a/etc/config.sh/functions +++ b/etc/config.sh/functions @@ -31,6 +31,7 @@ then foamClean=$WM_PROJECT_DIR/bin/foamCleanPath # Cleaning environment variables + unset -f _foamClean 2>/dev/null _foamClean() { foamVar_name=$1 @@ -41,6 +42,7 @@ then # Source an etc file, possibly with some verbosity # - use eval to avoid intermediate variables (ksh doesn't have 'local') + unset -f _foamEtc 2>/dev/null if [ "$FOAM_VERBOSE" -a "$PS1" ] then _foamEtc() @@ -55,18 +57,21 @@ then fi # Prepend PATH + unset -f _foamAddPath 2>/dev/null _foamAddPath() { [ -n "$1" ] && export PATH=$1:$PATH } # Prepend MANPATH + unset -f _foamAddMan 2>/dev/null _foamAddMan() { [ -n "$1" ] && export MANPATH=$1:$MANPATH } # Prepend LD_LIBRARY_PATH + unset -f _foamAddLib 2>/dev/null _foamAddLib() { [ -n "$1" ] && export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH @@ -83,6 +88,7 @@ then # 2) Use fallback if the previous failed # # Return 0 on success + unset -f _foamAddLibAuto 2>/dev/null _foamAddLibAuto() { # Note ksh does not have 'local' thus these ugly variable names @@ -150,6 +156,7 @@ then # Evaluate command-line parameters + unset -f _foamEval 2>/dev/null _foamEval() { while [ $# -gt 0 ]