diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 0a31ed9c48..5073744218 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -68,6 +68,7 @@ options: -config Add config directory prefix for shell type: with -csh* for a config.csh/ prefix with -sh* for a config.sh/ prefix + -etc=[DIR] set/unset FOAM_CONFIG_ETC for alternative etc directory -show-api Print META-INFO api value and exit -show-patch Print META-INFO patch value and exit -with-api=NUM Specify alternative api value to search with @@ -118,15 +119,6 @@ optMode=ugo # Default search = 'ugo' # Environment overrides case "$FOAM_CONFIG_MODE" in ([ugo]*) optMode="$FOAM_CONFIG_MODE" ;; esac -# Verify validity of FOAM_CONFIG_ETC -if [ -n "$FOAM_CONFIG_ETC" ] -then - if [ ! -d "$FOAM_CONFIG_ETC" ] || [ "$FOAM_CONFIG_ETC" = "$projectDir/etc" ] - then - # Bad directory or redundant value - unset FOAM_CONFIG_ETC - fi -fi #------------------------------------------------------------------------------- @@ -211,6 +203,10 @@ do optSilent=true ;; + -etc=*) + # FOAM_CONFIG_ETC for finding files. Empty unsets it (later) + export FOAM_CONFIG_ETC="${1#*=}" + ;; -prefix=* | -version=*) echo "ignored defunct option '${1%%=*}'" 1>&2 ;; @@ -237,6 +233,23 @@ done #------------------------------------------------------------------------------- +# Verify FOAM_CONFIG_ETC +if [ -n "$FOAM_CONFIG_ETC" ] +then + if [ "$FOAM_CONFIG_ETC" = "etc" ] \ + || [ "$FOAM_CONFIG_ETC" = "$projectDir/etc" ] + then + # Redundant value + unset FOAM_CONFIG_ETC + elif [ "${FOAM_CONFIG_ETC#/}" = "$FOAM_CONFIG_ETC" ] + then + # Relative to project-dir + FOAM_CONFIG_ETC="$projectDir/$FOAM_CONFIG_ETC" + fi +else + unset FOAM_CONFIG_ETC +fi + # Establish the API value [ -n "$projectApi" ] || projectApi=$(getApiInfo api) diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths index 03859f4ce7..27677be6bb 100755 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -71,7 +71,7 @@ Options -help-full Display full help and exit Basic - -etc=DIR set FOAM_CONFIG_ETC for alternative project files + -etc=[DIR] set/unset FOAM_CONFIG_ETC for alternative project files -project-path DIR specify 'WM_PROJECT_DIR' (eg, /opt/openfoam1806-patch1) -version VER specify project version (eg, v1806) -sp | -SP | -float32 single precision (WM_PRECISION_OPTION) @@ -416,8 +416,9 @@ CONFIG_CSH ## Basic ## -etc=*) - # Define FOAM_CONFIG_ETC for finding files + # FOAM_CONFIG_ETC for finding files. Empty unsets it export FOAM_CONFIG_ETC="${1#*=}" + [ -n "$FOAM_CONFIG_ETC" ] || unset FOAM_CONFIG_ETC ;; -project-path) diff --git a/etc/config.csh/setup b/etc/config.csh/setup index 0d43ccb033..5f9bec387f 100644 --- a/etc/config.csh/setup +++ b/etc/config.csh/setup @@ -127,12 +127,10 @@ while ( $#argv > 0 ) shift end -# The prefs may have injected a FOAM_CONFIG_ETC value. -# Verify that it makes sense before continuing. +# Verify FOAM_CONFIG_ETC (from calling environment or from prefs) if ( $?FOAM_CONFIG_ETC ) then - if ( ! -d "$FOAM_CONFIG_ETC" ) then - echo "Ignore invalid FOAM_CONFIG_ETC = $FOAM_CONFIG_ETC" - else if ( "$FOAM_CONFIG_ETC" == "$WM_PROJECT_DIR/etc" ) then + if ( "$FOAM_CONFIG_ETC" == "etc" || "$FOAM_CONFIG_ETC" == "$WM_PROJECT_DIR/etc" ) then + # Redundant value unsetenv FOAM_CONFIG_ETC endif endif diff --git a/etc/config.sh/setup b/etc/config.sh/setup index 48287d4f06..ed4df86dbf 100644 --- a/etc/config.sh/setup +++ b/etc/config.sh/setup @@ -115,19 +115,19 @@ else _foamEval "$@" fi -# The prefs may have injected a FOAM_CONFIG_ETC value. -# Verify that it makes sense before continuing. +# Verify FOAM_CONFIG_ETC (from calling environment or from prefs) if [ -n "$FOAM_CONFIG_ETC" ] then - if [ ! -d "$FOAM_CONFIG_ETC" ] - then - echo "Ignore invalid FOAM_CONFIG_ETC = $FOAM_CONFIG_ETC" 1>&2 - unset FOAM_CONFIG_ETC - elif [ "$FOAM_CONFIG_ETC" = "$WM_PROJECT_DIR/etc" ] + if [ "$FOAM_CONFIG_ETC" = "etc" ] \ + || [ "$FOAM_CONFIG_ETC" = "$WM_PROJECT_DIR/etc" ] then # Redundant value unset FOAM_CONFIG_ETC + else + export FOAM_CONFIG_ETC fi +else + unset FOAM_CONFIG_ETC fi