From 0a2768667f4aa0eb02e41ab2a2de72dbf00e4af6 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 15 Oct 2018 21:37:46 +0200 Subject: [PATCH] CONFIG: improve shell env handling of paths with spaces (#1007, #1008) - foamCleanPath now only splits the environment variable on ':', which allows other directories with spaces or '(..)' etc to pass through without major issue. - The filter arguments are split on whitespace, colons or semi-colons. --- bin/foamCleanPath | 69 +++++++++++++++++----------------- etc/bashrc | 12 +++--- etc/config.sh/ADIOS | 2 +- etc/config.sh/ADIOS2 | 2 +- etc/config.sh/CGAL | 2 +- etc/config.sh/FFTW | 2 +- etc/config.sh/aliases | 16 ++++---- etc/config.sh/bash_completion | 2 +- etc/config.sh/example/paraview | 4 +- etc/config.sh/functions | 33 ++++++++-------- etc/config.sh/gperftools | 2 +- etc/config.sh/hypre | 2 +- etc/config.sh/mpi | 10 ++--- etc/config.sh/paraview | 18 +++++---- etc/config.sh/petsc | 2 +- etc/config.sh/settings | 4 +- etc/config.sh/unset | 12 +++--- etc/config.sh/vtk | 2 +- 18 files changed, 101 insertions(+), 95 deletions(-) diff --git a/bin/foamCleanPath b/bin/foamCleanPath index 5d197ac0b1..f54575a8d9 100755 --- a/bin/foamCleanPath +++ b/bin/foamCleanPath @@ -14,20 +14,19 @@ # foamCleanPath # # Description -# Usage: foamCleanPath [OPTION] path [wildcard] .. [wildcard] -# foamCleanPath [OPTION] -env=name [wildcard1] .. [wildcardN] +# Usage: foamCleanPath [OPTION] path [filter] .. [filter] +# foamCleanPath [OPTION] -env=name [filter] .. [filter] # # Prints its argument (which should be a ':' separated path) # without the following: # - duplicate elements -# - elements whose start matches a wildcard +# - elements matching the specified filter(s) # - inaccessible directories (with the -strip option) # # Note -# - this routine fails when directories have embedded spaces -# - false matches possible if a wildcard contains '.' (sed regex) -# - the wildcards themselves can be written together and separated -# by colons or whitespace +# - false matches possible when the filter contains '.' (sed regex) etc. +# - a single composite filter can be passed in. This composite filter +# is assumed to be delimited by whitespace, colons or semi-colons. # # Examples for cleaning the path: # @@ -38,9 +37,9 @@ # cleaned=$(foamCleanPath -env=PATH dir1:dir2) && PATH=$cleaned # # - Using shell evaluation for the output -# eval $(foamCleanPath -sh=PATH "$PATH" dir1:dir2) -# eval $(foamCleanPath -sh=PATH -env=PATH dir1:dir2) -# eval $(foamCleanPath -sh-env=PATH dir1:dir2) +# eval $(foamCleanPath -sh=PATH $PATH" dir1:dir2) +# eval "$(foamCleanPath -sh=PATH -env=PATH dir1:dir2)" +# eval "$(foamCleanPath -sh-env=PATH dir1:dir2)" # # - Similarly for c-shell # eval `foamCleanPath -csh-env=PATH dir1:dir2` @@ -48,28 +47,27 @@ #------------------------------------------------------------------------------ usage() { cat <<USAGE 1>&2 -Usage: foamCleanPath [OPTION] path [wildcard1] .. [wildcardN]] - foamCleanPath [OPTION] -env=name [wildcard1] .. [wildcardN] - +Usage: foamCleanPath [OPTION] path [filter] .. [filter] + foamCleanPath [OPTION] -env=name [filter] .. [filter] options: -csh=NAME Produce 'setenv NAME ...' output for csh eval -sh=NAME Produce 'NAME=...' output for sh eval -csh-env=NAME As per -csh, with -env for initial content -sh-env=NAME As per -sh, with -env for initial content -env=NAME Evaluate NAME to obtain initial content - -debug print debug information to stderr - -strip remove inaccessible directories - -verbose report some progress (input, output, ...) - -help print the usage + -debug Print debug information to stderr + -strip Remove inaccessible directories + -verbose Report some progress (input, output, ...) + -help Print the usage Prints its argument (which should be a ':' separated list) cleansed from * duplicate elements - * elements whose start matches one of the wildcard(s) + * elements whose start matches one of the filters * inaccessible directories (the -strip option) Exit status 0 on success - 1 for miscellaneous errors. + 1 general error 2 initial value of 'path' is empty USAGE @@ -169,19 +167,20 @@ else printDebug() { true; } # No-op fi -# Check directory existence (optional) +# Optional test for directory existence if [ -n "$optStrip" ] then - isDir() { test -d "$1"; } # Check for directory + isDir() { test -d "$1"; } # Check for directory existence else - isDir() { true; } # No check (always true) + isDir() { test -n "$1"; } # Only check for non-zero string fi -# The "wildcard1 ... wildcardN" may have been passed as a single parameter -# or may contain ':' separators +# The "filter ... filterN" may have been passed as a single parameter +# or may contain ':' separators. +# Currently (OCT-2018) also accept split on whitespace too. oldIFS="$IFS" # Preserve initial IFS -IFS=':; ' # Split on colon, whitespace (semi-colon for good measure) +IFS=':; ' # Split on colon, semicolon, whitespace set -- $* if [ -n "$optVerbose" ] @@ -192,22 +191,20 @@ fi printDebug "input>$dirList<" -# Strip out wildcards via sed. Path and wildcard cannot contain '?'. -for wildcard +# Apply filters via sed. Path and filter cannot contain '?'. +for filter do - if [ -n "$wildcard" ] + if [ -n "$filter" ] then - printDebug "remove>$wildcard<" - dirList=$(echo "$dirList:" | sed -e "s?${wildcard}[^:]*:??g") + printDebug "remove>$filter<" + dirList=$(echo "$dirList:" | sed -e "s?${filter}[^:]*:??g") fi done printDebug "intermediate>$dirList<" -IFS=':; ' # Split on colon, whitespace (semi-colon for good measure) +IFS=':' # Split on colon. No split on whitespace. set -- $dirList -IFS="$oldIFS" # Restore initial IFS - # Rebuild the list unset dirList for dir @@ -227,12 +224,14 @@ do fi done +IFS="$oldIFS" # Restore initial IFS + printDebug "output>$dirList<" if [ -n "$optVerbose" ] then - echo "output: $dirList" 1>&2 + echo "output: \"$dirList\"" 1>&2 fi -echo "$shellOutput$dirList" +echo "$shellOutput\"$dirList\"" #------------------------------------------------------------------------------ diff --git a/etc/bashrc b/etc/bashrc index f076066796..7340532d7e 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -47,10 +47,10 @@ export WM_PROJECT_VERSION=plus # set one of the fallback values to an appropriate path. # -- rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}" -[ -n "$rc" ] && FOAM_INST_DIR=$(\cd $(dirname $rc)/../.. && \pwd -L) || \ -FOAM_INST_DIR=$HOME/$WM_PROJECT -# FOAM_INST_DIR=/opt/$WM_PROJECT -# FOAM_INST_DIR=/usr/local/$WM_PROJECT +[ -n "$rc" ] && FOAM_INST_DIR="$(\cd $(dirname $rc)/../.. && \pwd -L)" || \ +FOAM_INST_DIR="$HOME/$WM_PROJECT" +# FOAM_INST_DIR="/opt/$WM_PROJECT" +# FOAM_INST_DIR="/usr/local/$WM_PROJECT" # # END OF (NORMAL) USER EDITABLE PART ################################################################################ @@ -153,7 +153,7 @@ then unset FOAM_SETTINGS else export FOAM_SETTINGS - _foamEval $@ + _foamEval "$@" fi # Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH) @@ -170,7 +170,7 @@ _foamEtc -config settings # Setup for third-party packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc -config mpi -_foamEtc -config paraview -- $@ # Pass through for evaluation +_foamEtc -config paraview -- "$@" # Pass through for evaluation _foamEtc -config vtk _foamEtc -config ensight _foamEtc -config gperftools diff --git a/etc/config.sh/ADIOS b/etc/config.sh/ADIOS index 54534209dd..df1fec50e2 100644 --- a/etc/config.sh/ADIOS +++ b/etc/config.sh/ADIOS @@ -37,7 +37,7 @@ export ADIOS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using adios ($adios_version) -> $ADIOS_ARCH_PATH" 1>&2 fi diff --git a/etc/config.sh/ADIOS2 b/etc/config.sh/ADIOS2 index b77593e9a5..3719333378 100644 --- a/etc/config.sh/ADIOS2 +++ b/etc/config.sh/ADIOS2 @@ -25,7 +25,7 @@ export ADIOS2_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adio # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" 1>&2 fi diff --git a/etc/config.sh/CGAL b/etc/config.sh/CGAL index 9acf55892b..1e5558017b 100644 --- a/etc/config.sh/CGAL +++ b/etc/config.sh/CGAL @@ -49,7 +49,7 @@ export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_v # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using boost ($boost_version) -> $BOOST_ARCH_PATH" 1>&2 echo "Using CGAL ($cgal_version) -> $CGAL_ARCH_PATH" 1>&2 diff --git a/etc/config.sh/FFTW b/etc/config.sh/FFTW index f20d2b5421..f273b64267 100644 --- a/etc/config.sh/FFTW +++ b/etc/config.sh/FFTW @@ -38,7 +38,7 @@ export FFTW_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_v # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using fftw ($fftw_version) -> $FFTW_ARCH_PATH" 1>&2 fi diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases index 2a5c579064..a0a54de311 100644 --- a/etc/config.sh/aliases +++ b/etc/config.sh/aliases @@ -58,10 +58,10 @@ alias uutil='cd $WM_PROJECT_USER_DIR/applications/utilities' unset -f wmRefresh 2>/dev/null wmRefresh() { - local projectDir=$WM_PROJECT_DIR - local foamSettings=$FOAM_SETTINGS + local projectDir="$WM_PROJECT_DIR" + local foamSettings="$FOAM_SETTINGS" wmUnset - . $projectDir/etc/bashrc $foamSettings + . "$projectDir/etc/bashrc" "$foamSettings" } @@ -73,13 +73,13 @@ foamVersion() if [ "$#" -gt 0 ] then local dir="${WM_PROJECT_DIR%/*}" # Parent directory - local ver=$1 + local ver="$1" shift if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ] then wmUnset - . $dir/OpenFOAM-$ver/etc/bashrc + . "$dir/OpenFOAM-$ver/etc/bashrc" foam echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2 else @@ -104,7 +104,7 @@ foamVersion() unset -f foamPV 2>/dev/null foamPV() { - . $WM_PROJECT_DIR/etc/config.sh/paraview "${@+ParaView_VERSION=$@}" + . "$WM_PROJECT_DIR/etc/config.sh/paraview" "${@+ParaView_VERSION=$@}" local pvdir="${ParaView_DIR##*/}" echo "${pvdir:-ParaView_DIR not set}" 1>&2 } @@ -117,13 +117,13 @@ foamPwd() { if [ -d "$WM_PROJECT_DIR" ] then - echo $PWD | sed \ + echo "$PWD" | sed \ -e "s#^${FOAM_RUN}#\$FOAM_RUN#;" \ -e "s#^${WM_PROJECT_DIR}#\$WM_PROJECT_DIR#;" \ -e "s#^${WM_PROJECT_USER_DIR}#\$WM_PROJECT_USER_DIR#;" \ -e "s#^${HOME}#\$HOME#"; else - echo $PWD | sed -e "s#^${HOME}#\$HOME#;" + echo "$PWD" | sed -e "s#^${HOME}#\$HOME#;" fi } diff --git a/etc/config.sh/bash_completion b/etc/config.sh/bash_completion index d2ea0b0315..98c3556b20 100644 --- a/etc/config.sh/bash_completion +++ b/etc/config.sh/bash_completion @@ -37,7 +37,7 @@ then foamOldDirs="$(complete 2>/dev/null | sed -ne 's/^.*-F _of_.* \(..*\)$/\1/p')" for cleaned in $foamOldDirs do - complete -r $cleaned 2>/dev/null + complete -r "$cleaned" 2>/dev/null done fi diff --git a/etc/config.sh/example/paraview b/etc/config.sh/example/paraview index fb91cc1699..ced794a3f3 100644 --- a/etc/config.sh/example/paraview +++ b/etc/config.sh/example/paraview @@ -27,6 +27,8 @@ pv=5.5.0 pv=5.5.0-mpipy qt=qt-5.9.0 -eval $(foamEtcFile -sh -config -mode=o paraview -- ParaView_VERSION=$pv ParaView_QT=$qt) +eval \ + "$(foamEtcFile -sh -config -mode=o paraview -- \ + ParaView_VERSION=$pv ParaView_QT=$qt)" #------------------------------------------------------------------------------ diff --git a/etc/config.sh/functions b/etc/config.sh/functions index 39afd27bd8..cd4f9d2550 100644 --- a/etc/config.sh/functions +++ b/etc/config.sh/functions @@ -28,22 +28,22 @@ then WM_SHELL_FUNCTIONS=loaded # Cleaning environment variables - foamClean=$WM_PROJECT_DIR/bin/foamCleanPath + foamClean="$WM_PROJECT_DIR/bin/foamCleanPath" # Cleaning environment variables unset -f _foamClean 2>/dev/null _foamClean() { - foamVar_name=$1 + foamVar_name="$1" shift - eval $($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=$foamVar_name "$@") - unset foamVar_name + eval "$($foamClean -sh-env=$foamVar_name $@)" + unset "foamVar_name" } # 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" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then _foamEtc() { @@ -60,21 +60,21 @@ then unset -f _foamAddPath 2>/dev/null _foamAddPath() { - [ -n "$1" ] && export PATH=$1:$PATH + [ -n "$1" ] && export PATH="$1:$PATH" } # Prepend MANPATH unset -f _foamAddMan 2>/dev/null _foamAddMan() { - [ -n "$1" ] && export MANPATH=$1:$MANPATH + [ -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 + [ -n "$1" ] && export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH" } # Prepend to LD_LIBRARY_PATH with additional checking @@ -106,7 +106,7 @@ then do if [ -d "$foamVar_prefix/$foamVar_end" ] then - export LD_LIBRARY_PATH=$foamVar_prefix/$foamVar_end:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH="$foamVar_prefix/$foamVar_end:$LD_LIBRARY_PATH" unset foamVar_prefix foamVar_end return 0 fi @@ -119,10 +119,10 @@ then then case "$foamVar_end" in /*) # An absolute path - export LD_LIBRARY_PATH=$foamVar_end:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH="$foamVar_end:$LD_LIBRARY_PATH" ;; (*) # Relative to prefix - export LD_LIBRARY_PATH=$foamVar_prefix/$foamVar_end:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH="$foamVar_prefix/$foamVar_end:$LD_LIBRARY_PATH" ;; esac unset foamVar_prefix foamVar_end @@ -143,7 +143,7 @@ then # Prepend DYLD_LIBRARY_PATH _foamAddLib() { - [ -n "$1" ] && export DYLD_LIBRARY_PATH=$1:$DYLD_LIBRARY_PATH + [ -n "$1" ] && export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH" } # Prepend to DYLD_LIBRARY_PATH with additional checking @@ -168,19 +168,22 @@ then ;; *=) # name= -> unset name - [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "unset ${1%=}" 1>&2 + [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \ + && echo "unset ${1%=}" 1>&2 eval "unset ${1%=}" ;; *=*) # name=value -> export name=value - [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1" 1>&2 + [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \ + && echo "export $1" 1>&2 eval "export $1" ;; *) # Filename: source it if [ -f "$1" ] then - [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2 + [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \ + && echo "Using: $1" 1>&2 . "$1" else _foamEtc -silent "$1" diff --git a/etc/config.sh/gperftools b/etc/config.sh/gperftools index f23ee42bbb..e1d2a01a1c 100644 --- a/etc/config.sh/gperftools +++ b/etc/config.sh/gperftools @@ -40,7 +40,7 @@ GPERFTOOLS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$gperfto # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using gperftools ($gperftools_version) -> $GPERFTOOLS_ARCH_PATH" 1>&2 fi diff --git a/etc/config.sh/hypre b/etc/config.sh/hypre index 79fc3a316e..7850728e41 100644 --- a/etc/config.sh/hypre +++ b/etc/config.sh/hypre @@ -31,7 +31,7 @@ export HYPRE_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRE # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using hypre ($hypre_version) -> $HYPRE_ARCH_PATH" 1>&2 fi diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi index 4feee87312..bba158bc4e 100644 --- a/etc/config.sh/mpi +++ b/etc/config.sh/mpi @@ -68,7 +68,7 @@ OPENMPI) # Inform openmpi where to find its install directory export OPAL_PREFIX=$MPI_ARCH_PATH - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using $WM_MPLIB" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2 @@ -168,7 +168,7 @@ CRAY-MPICH) export FOAM_MPI=cray-mpich export MPI_ARCH_PATH=$MPICH_DIR - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using $WM_MPLIB" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2 @@ -247,7 +247,7 @@ SGIMPI) echo " Currently using '$MPI_ARCH_PATH'" 1>&2 } - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using $WM_MPLIB" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2 @@ -269,7 +269,7 @@ INTELMPI) # If subdirectory is version number only, prefix with 'impi-' case "$FOAM_MPI" in ([0-9]*) FOAM_MPI="impi-$FOAM_MPI";; esac - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using $WM_MPLIB" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2 @@ -283,7 +283,7 @@ INTELMPI) # If subdirectory is version number only, prefix with 'impi-' case "$FOAM_MPI" in ([0-9]*) FOAM_MPI="impi-$FOAM_MPI";; esac - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using $WM_MPLIB" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2 diff --git a/etc/config.sh/paraview b/etc/config.sh/paraview index 41c8c8e20c..591febeb8b 100644 --- a/etc/config.sh/paraview +++ b/etc/config.sh/paraview @@ -58,18 +58,20 @@ pv_api=auto # Either auto or pair of (major.minor) digits archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER" # Clean PATH and LD_LIBRARY_PATH -eval $($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \ - "$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-") +eval \ + "$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \ + $ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-)" -eval $($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=LD_LIBRARY_PATH \ - "$ParaView_DIR $archDir/ParaView- $archDir/qt-") +eval \ + "$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=LD_LIBRARY_PATH \ + $ParaView_DIR $archDir/ParaView- $archDir/qt-)" # ThirdParty cmake -cmake=$archDir/$cmake_version -if [ -r $cmake/bin/cmake ] +cmake="$archDir/$cmake_version" +if [ -r "$cmake/bin/cmake" ] then # _foamAddPath not available when foamPV function is used - PATH=$cmake/bin:$PATH + PATH="$cmake/bin:$PATH" fi # Evaluate command-line parameters for ParaView @@ -159,7 +161,7 @@ then ;; esac - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using paraview" echo " ParaView_DIR : $ParaView_DIR" diff --git a/etc/config.sh/petsc b/etc/config.sh/petsc index 25448b7977..937d4ff508 100644 --- a/etc/config.sh/petsc +++ b/etc/config.sh/petsc @@ -31,7 +31,7 @@ export PETSC_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRE # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using petsc ($petsc_version) -> $PETSC_ARCH_PATH" 1>&2 fi diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 6b51ae3b05..c03bcdb230 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -273,7 +273,7 @@ GCC_NOT_FOUND _foamAddLibAuto $mpcDir - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using ThirdParty compiler" echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})" @@ -299,7 +299,7 @@ CLANG_NOT_FOUND _foamAddPath $clangDir/bin _foamAddLib $clangDir/lib # For things like libomp (openmp) etc - if [ "$FOAM_VERBOSE" -a "$PS1" ] + if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using ThirdParty compiler" echo " ${clangDir##*/}" diff --git a/etc/config.sh/unset b/etc/config.sh/unset index 871afe1ecd..4ebfe76185 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -92,7 +92,7 @@ unset MPI_ARCH_PATH unset MPI_BUFFER_SIZE # Undefine OPAL_PREFIX if set to one of the paths on foamOldDirs -if [ -z "$($foamClean -env=OPAL_PREFIX "$foamOldDirs")" ] +if [ -n "$foamClean" ] && [ -z "$($foamClean -env=OPAL_PREFIX $foamOldDirs)" ] then unset OPAL_PREFIX fi @@ -108,7 +108,7 @@ unset PV_PLUGIN_PATH unset VTK_DIR # Undefine Qt5_DIR if set to one of the paths on foamOldDirs -if [ -z "$($foamClean -env=Qt5_DIR "$foamOldDirs")" ] +if [ -n "$foamClean" ] && [ -z "$($foamClean -env=Qt5_DIR $foamOldDirs)" ] then unset Qt5_DIR fi @@ -137,9 +137,9 @@ unset SCOTCH_ARCH_PATH if [ -n "$foamClean" ] then - eval $($foamClean -sh-env=PATH "$foamOldDirs") - eval $($foamClean -sh-env=LD_LIBRARY_PATH "$foamOldDirs") - eval $($foamClean -sh-env=MANPATH "$foamOldDirs") + eval "$($foamClean -sh-env=PATH $foamOldDirs)" + eval "$($foamClean -sh-env=LD_LIBRARY_PATH $foamOldDirs)" + eval "$($foamClean -sh-env=MANPATH $foamOldDirs)" fi [ -n "$LD_LIBRARY_PATH" ] || unset LD_LIBRARY_PATH @@ -189,7 +189,7 @@ unset -f foamPV 2>/dev/null foamOldDirs="$(complete 2>/dev/null | sed -ne 's/^.*-F _of_.* \(..*\)$/\1/p')" for cleaned in $foamOldDirs do - complete -r $cleaned 2>/dev/null + complete -r "$cleaned" 2>/dev/null done # Completion functions diff --git a/etc/config.sh/vtk b/etc/config.sh/vtk index 6e4df894fa..242407e977 100644 --- a/etc/config.sh/vtk +++ b/etc/config.sh/vtk @@ -39,7 +39,7 @@ export MESA_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mesa_v # END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ -if [ "$FOAM_VERBOSE" -a "$PS1" ] +if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] then echo "Using vtk ($vtk_version) -> $VTK_DIR" 1>&2 echo "Using mesa ($mesa_version) -> $MESA_ARCH_PATH" 1>&2 -- GitLab