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.
This commit is contained in:
Mark Olesen
2018-10-15 21:37:46 +02:00
parent 5c8a1b746d
commit 50852b3392
18 changed files with 101 additions and 95 deletions

View File

@ -14,20 +14,19 @@
# foamCleanPath # foamCleanPath
# #
# Description # Description
# Usage: foamCleanPath [OPTION] path [wildcard] .. [wildcard] # Usage: foamCleanPath [OPTION] path [filter] .. [filter]
# foamCleanPath [OPTION] -env=name [wildcard1] .. [wildcardN] # foamCleanPath [OPTION] -env=name [filter] .. [filter]
# #
# Prints its argument (which should be a ':' separated path) # Prints its argument (which should be a ':' separated path)
# without the following: # without the following:
# - duplicate elements # - duplicate elements
# - elements whose start matches a wildcard # - elements matching the specified filter(s)
# - inaccessible directories (with the -strip option) # - inaccessible directories (with the -strip option)
# #
# Note # Note
# - this routine fails when directories have embedded spaces # - false matches possible when the filter contains '.' (sed regex) etc.
# - false matches possible if a wildcard contains '.' (sed regex) # - a single composite filter can be passed in. This composite filter
# - the wildcards themselves can be written together and separated # is assumed to be delimited by whitespace, colons or semi-colons.
# by colons or whitespace
# #
# Examples for cleaning the path: # Examples for cleaning the path:
# #
@ -38,9 +37,9 @@
# cleaned=$(foamCleanPath -env=PATH dir1:dir2) && PATH=$cleaned # cleaned=$(foamCleanPath -env=PATH dir1:dir2) && PATH=$cleaned
# #
# - Using shell evaluation for the output # - Using shell evaluation for the output
# eval $(foamCleanPath -sh=PATH "$PATH" dir1:dir2) # eval $(foamCleanPath -sh=PATH $PATH" dir1:dir2)
# eval $(foamCleanPath -sh=PATH -env=PATH dir1:dir2) # eval "$(foamCleanPath -sh=PATH -env=PATH dir1:dir2)"
# eval $(foamCleanPath -sh-env=PATH dir1:dir2) # eval "$(foamCleanPath -sh-env=PATH dir1:dir2)"
# #
# - Similarly for c-shell # - Similarly for c-shell
# eval `foamCleanPath -csh-env=PATH dir1:dir2` # eval `foamCleanPath -csh-env=PATH dir1:dir2`
@ -48,28 +47,27 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
cat <<USAGE 1>&2 cat <<USAGE 1>&2
Usage: foamCleanPath [OPTION] path [wildcard1] .. [wildcardN]] Usage: foamCleanPath [OPTION] path [filter] .. [filter]
foamCleanPath [OPTION] -env=name [wildcard1] .. [wildcardN] foamCleanPath [OPTION] -env=name [filter] .. [filter]
options: options:
-csh=NAME Produce 'setenv NAME ...' output for csh eval -csh=NAME Produce 'setenv NAME ...' output for csh eval
-sh=NAME Produce 'NAME=...' output for sh eval -sh=NAME Produce 'NAME=...' output for sh eval
-csh-env=NAME As per -csh, with -env for initial content -csh-env=NAME As per -csh, with -env for initial content
-sh-env=NAME As per -sh, with -env for initial content -sh-env=NAME As per -sh, with -env for initial content
-env=NAME Evaluate NAME to obtain initial content -env=NAME Evaluate NAME to obtain initial content
-debug print debug information to stderr -debug Print debug information to stderr
-strip remove inaccessible directories -strip Remove inaccessible directories
-verbose report some progress (input, output, ...) -verbose Report some progress (input, output, ...)
-help print the usage -help Print the usage
Prints its argument (which should be a ':' separated list) cleansed from Prints its argument (which should be a ':' separated list) cleansed from
* duplicate elements * duplicate elements
* elements whose start matches one of the wildcard(s) * elements whose start matches one of the filters
* inaccessible directories (the -strip option) * inaccessible directories (the -strip option)
Exit status Exit status
0 on success 0 on success
1 for miscellaneous errors. 1 general error
2 initial value of 'path' is empty 2 initial value of 'path' is empty
USAGE USAGE
@ -169,19 +167,20 @@ else
printDebug() { true; } # No-op printDebug() { true; } # No-op
fi fi
# Check directory existence (optional) # Optional test for directory existence
if [ -n "$optStrip" ] if [ -n "$optStrip" ]
then then
isDir() { test -d "$1"; } # Check for directory isDir() { test -d "$1"; } # Check for directory existence
else else
isDir() { true; } # No check (always true) isDir() { test -n "$1"; } # Only check for non-zero string
fi fi
# The "wildcard1 ... wildcardN" may have been passed as a single parameter # The "filter ... filterN" may have been passed as a single parameter
# or may contain ':' separators # or may contain ':' separators.
# Currently (OCT-2018) also accept split on whitespace too.
oldIFS="$IFS" # Preserve initial IFS oldIFS="$IFS" # Preserve initial IFS
IFS=':; ' # Split on colon, whitespace (semi-colon for good measure) IFS=':; ' # Split on colon, semicolon, whitespace
set -- $* set -- $*
if [ -n "$optVerbose" ] if [ -n "$optVerbose" ]
@ -192,22 +191,20 @@ fi
printDebug "input>$dirList<" printDebug "input>$dirList<"
# Strip out wildcards via sed. Path and wildcard cannot contain '?'. # Apply filters via sed. Path and filter cannot contain '?'.
for wildcard for filter
do do
if [ -n "$wildcard" ] if [ -n "$filter" ]
then then
printDebug "remove>$wildcard<" printDebug "remove>$filter<"
dirList=$(echo "$dirList:" | sed -e "s?${wildcard}[^:]*:??g") dirList=$(echo "$dirList:" | sed -e "s?${filter}[^:]*:??g")
fi fi
done done
printDebug "intermediate>$dirList<" printDebug "intermediate>$dirList<"
IFS=':; ' # Split on colon, whitespace (semi-colon for good measure) IFS=':' # Split on colon. No split on whitespace.
set -- $dirList set -- $dirList
IFS="$oldIFS" # Restore initial IFS
# Rebuild the list # Rebuild the list
unset dirList unset dirList
for dir for dir
@ -227,12 +224,14 @@ do
fi fi
done done
IFS="$oldIFS" # Restore initial IFS
printDebug "output>$dirList<" printDebug "output>$dirList<"
if [ -n "$optVerbose" ] if [ -n "$optVerbose" ]
then then
echo "output: $dirList" 1>&2 echo "output: \"$dirList\"" 1>&2
fi fi
echo "$shellOutput$dirList" echo "$shellOutput\"$dirList\""
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -47,10 +47,10 @@ export WM_PROJECT_VERSION=plus
# set one of the fallback values to an appropriate path. # set one of the fallback values to an appropriate path.
# -- # --
rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}" rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
[ -n "$rc" ] && FOAM_INST_DIR=$(\cd $(dirname $rc)/../.. && \pwd -L) || \ [ -n "$rc" ] && FOAM_INST_DIR="$(\cd $(dirname $rc)/../.. && \pwd -L)" || \
FOAM_INST_DIR=$HOME/$WM_PROJECT FOAM_INST_DIR="$HOME/$WM_PROJECT"
# FOAM_INST_DIR=/opt/$WM_PROJECT # FOAM_INST_DIR="/opt/$WM_PROJECT"
# FOAM_INST_DIR=/usr/local/$WM_PROJECT # FOAM_INST_DIR="/usr/local/$WM_PROJECT"
# #
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
################################################################################ ################################################################################
@ -153,7 +153,7 @@ then
unset FOAM_SETTINGS unset FOAM_SETTINGS
else else
export FOAM_SETTINGS export FOAM_SETTINGS
_foamEval $@ _foamEval "$@"
fi fi
# Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH) # Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH)
@ -170,7 +170,7 @@ _foamEtc -config settings
# Setup for third-party packages # Setup for third-party packages
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamEtc -config mpi _foamEtc -config mpi
_foamEtc -config paraview -- $@ # Pass through for evaluation _foamEtc -config paraview -- "$@" # Pass through for evaluation
_foamEtc -config vtk _foamEtc -config vtk
_foamEtc -config ensight _foamEtc -config ensight
_foamEtc -config gperftools _foamEtc -config gperftools

View File

@ -37,7 +37,7 @@ export ADIOS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using adios ($adios_version) -> $ADIOS_ARCH_PATH" 1>&2 echo "Using adios ($adios_version) -> $ADIOS_ARCH_PATH" 1>&2
fi fi

View File

@ -25,7 +25,7 @@ export ADIOS2_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adio
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" 1>&2 echo "Using adios ($adios2_version) -> $ADIOS2_ARCH_PATH" 1>&2
fi fi

View File

@ -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 # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using boost ($boost_version) -> $BOOST_ARCH_PATH" 1>&2 echo "Using boost ($boost_version) -> $BOOST_ARCH_PATH" 1>&2
echo "Using CGAL ($cgal_version) -> $CGAL_ARCH_PATH" 1>&2 echo "Using CGAL ($cgal_version) -> $CGAL_ARCH_PATH" 1>&2

View File

@ -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 # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using fftw ($fftw_version) -> $FFTW_ARCH_PATH" 1>&2 echo "Using fftw ($fftw_version) -> $FFTW_ARCH_PATH" 1>&2
fi fi

View File

@ -58,10 +58,10 @@ alias uutil='cd $WM_PROJECT_USER_DIR/applications/utilities'
unset -f wmRefresh 2>/dev/null unset -f wmRefresh 2>/dev/null
wmRefresh() wmRefresh()
{ {
local projectDir=$WM_PROJECT_DIR local projectDir="$WM_PROJECT_DIR"
local foamSettings=$FOAM_SETTINGS local foamSettings="$FOAM_SETTINGS"
wmUnset wmUnset
. $projectDir/etc/bashrc $foamSettings . "$projectDir/etc/bashrc" "$foamSettings"
} }
@ -73,13 +73,13 @@ foamVersion()
if [ "$#" -gt 0 ] if [ "$#" -gt 0 ]
then then
local dir="${WM_PROJECT_DIR%/*}" # Parent directory local dir="${WM_PROJECT_DIR%/*}" # Parent directory
local ver=$1 local ver="$1"
shift shift
if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ] if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ]
then then
wmUnset wmUnset
. $dir/OpenFOAM-$ver/etc/bashrc . "$dir/OpenFOAM-$ver/etc/bashrc"
foam foam
echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2 echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2
else else
@ -104,7 +104,7 @@ foamVersion()
unset -f foamPV 2>/dev/null unset -f foamPV 2>/dev/null
foamPV() foamPV()
{ {
. $WM_PROJECT_DIR/etc/config.sh/paraview "${@+ParaView_VERSION=$@}" . "$WM_PROJECT_DIR/etc/config.sh/paraview" "${@+ParaView_VERSION=$@}"
local pvdir="${ParaView_DIR##*/}" local pvdir="${ParaView_DIR##*/}"
echo "${pvdir:-ParaView_DIR not set}" 1>&2 echo "${pvdir:-ParaView_DIR not set}" 1>&2
} }
@ -117,13 +117,13 @@ foamPwd()
{ {
if [ -d "$WM_PROJECT_DIR" ] if [ -d "$WM_PROJECT_DIR" ]
then then
echo $PWD | sed \ echo "$PWD" | sed \
-e "s#^${FOAM_RUN}#\$FOAM_RUN#;" \ -e "s#^${FOAM_RUN}#\$FOAM_RUN#;" \
-e "s#^${WM_PROJECT_DIR}#\$WM_PROJECT_DIR#;" \ -e "s#^${WM_PROJECT_DIR}#\$WM_PROJECT_DIR#;" \
-e "s#^${WM_PROJECT_USER_DIR}#\$WM_PROJECT_USER_DIR#;" \ -e "s#^${WM_PROJECT_USER_DIR}#\$WM_PROJECT_USER_DIR#;" \
-e "s#^${HOME}#\$HOME#"; -e "s#^${HOME}#\$HOME#";
else else
echo $PWD | sed -e "s#^${HOME}#\$HOME#;" echo "$PWD" | sed -e "s#^${HOME}#\$HOME#;"
fi fi
} }

View File

@ -37,7 +37,7 @@ then
foamOldDirs="$(complete 2>/dev/null | sed -ne 's/^.*-F _of_.* \(..*\)$/\1/p')" foamOldDirs="$(complete 2>/dev/null | sed -ne 's/^.*-F _of_.* \(..*\)$/\1/p')"
for cleaned in $foamOldDirs for cleaned in $foamOldDirs
do do
complete -r $cleaned 2>/dev/null complete -r "$cleaned" 2>/dev/null
done done
fi fi

View File

@ -27,6 +27,8 @@ pv=5.5.0
pv=5.5.0-mpipy pv=5.5.0-mpipy
qt=qt-5.9.0 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)"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -28,22 +28,22 @@ then
WM_SHELL_FUNCTIONS=loaded WM_SHELL_FUNCTIONS=loaded
# Cleaning environment variables # Cleaning environment variables
foamClean=$WM_PROJECT_DIR/bin/foamCleanPath foamClean="$WM_PROJECT_DIR/bin/foamCleanPath"
# Cleaning environment variables # Cleaning environment variables
unset -f _foamClean 2>/dev/null unset -f _foamClean 2>/dev/null
_foamClean() _foamClean()
{ {
foamVar_name=$1 foamVar_name="$1"
shift shift
eval $($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=$foamVar_name "$@") eval "$($foamClean -sh-env=$foamVar_name $@)"
unset foamVar_name unset "foamVar_name"
} }
# Source an etc file, possibly with some verbosity # Source an etc file, possibly with some verbosity
# - use eval to avoid intermediate variables (ksh doesn't have 'local') # - use eval to avoid intermediate variables (ksh doesn't have 'local')
unset -f _foamEtc 2>/dev/null unset -f _foamEtc 2>/dev/null
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
_foamEtc() _foamEtc()
{ {
@ -60,21 +60,21 @@ then
unset -f _foamAddPath 2>/dev/null unset -f _foamAddPath 2>/dev/null
_foamAddPath() _foamAddPath()
{ {
[ -n "$1" ] && export PATH=$1:$PATH [ -n "$1" ] && export PATH="$1:$PATH"
} }
# Prepend MANPATH # Prepend MANPATH
unset -f _foamAddMan 2>/dev/null unset -f _foamAddMan 2>/dev/null
_foamAddMan() _foamAddMan()
{ {
[ -n "$1" ] && export MANPATH=$1:$MANPATH [ -n "$1" ] && export MANPATH="$1:$MANPATH"
} }
# Prepend LD_LIBRARY_PATH # Prepend LD_LIBRARY_PATH
unset -f _foamAddLib 2>/dev/null unset -f _foamAddLib 2>/dev/null
_foamAddLib() _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 # Prepend to LD_LIBRARY_PATH with additional checking
@ -106,7 +106,7 @@ then
do do
if [ -d "$foamVar_prefix/$foamVar_end" ] if [ -d "$foamVar_prefix/$foamVar_end" ]
then 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 unset foamVar_prefix foamVar_end
return 0 return 0
fi fi
@ -119,10 +119,10 @@ then
then then
case "$foamVar_end" in case "$foamVar_end" in
/*) # An absolute path /*) # An absolute path
export LD_LIBRARY_PATH=$foamVar_end:$LD_LIBRARY_PATH export LD_LIBRARY_PATH="$foamVar_end:$LD_LIBRARY_PATH"
;; ;;
(*) # Relative to prefix (*) # 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 esac
unset foamVar_prefix foamVar_end unset foamVar_prefix foamVar_end
@ -143,7 +143,7 @@ then
# Prepend DYLD_LIBRARY_PATH # Prepend DYLD_LIBRARY_PATH
_foamAddLib() _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 # Prepend to DYLD_LIBRARY_PATH with additional checking
@ -168,19 +168,22 @@ then
;; ;;
*=) *=)
# name= -> unset name # 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%=}" eval "unset ${1%=}"
;; ;;
*=*) *=*)
# name=value -> export name=value # 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" eval "export $1"
;; ;;
*) *)
# Filename: source it # Filename: source it
if [ -f "$1" ] if [ -f "$1" ]
then then
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2 [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "Using: $1" 1>&2
. "$1" . "$1"
else else
_foamEtc -silent "$1" _foamEtc -silent "$1"

View File

@ -40,7 +40,7 @@ GPERFTOOLS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$gperfto
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using gperftools ($gperftools_version) -> $GPERFTOOLS_ARCH_PATH" 1>&2 echo "Using gperftools ($gperftools_version) -> $GPERFTOOLS_ARCH_PATH" 1>&2
fi fi

View File

@ -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 # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using hypre ($hypre_version) -> $HYPRE_ARCH_PATH" 1>&2 echo "Using hypre ($hypre_version) -> $HYPRE_ARCH_PATH" 1>&2
fi fi

View File

@ -68,7 +68,7 @@ OPENMPI)
# Inform openmpi where to find its install directory # Inform openmpi where to find its install directory
export OPAL_PREFIX=$MPI_ARCH_PATH export OPAL_PREFIX=$MPI_ARCH_PATH
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using $WM_MPLIB" 1>&2 echo "Using $WM_MPLIB" 1>&2
echo " FOAM_MPI : $FOAM_MPI" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2
@ -168,7 +168,7 @@ CRAY-MPICH)
export FOAM_MPI=cray-mpich export FOAM_MPI=cray-mpich
export MPI_ARCH_PATH=$MPICH_DIR export MPI_ARCH_PATH=$MPICH_DIR
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using $WM_MPLIB" 1>&2 echo "Using $WM_MPLIB" 1>&2
echo " FOAM_MPI : $FOAM_MPI" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2
@ -247,7 +247,7 @@ SGIMPI)
echo " Currently using '$MPI_ARCH_PATH'" 1>&2 echo " Currently using '$MPI_ARCH_PATH'" 1>&2
} }
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using $WM_MPLIB" 1>&2 echo "Using $WM_MPLIB" 1>&2
echo " FOAM_MPI : $FOAM_MPI" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2
@ -269,7 +269,7 @@ INTELMPI)
# If subdirectory is version number only, prefix with 'impi-' # If subdirectory is version number only, prefix with 'impi-'
case "$FOAM_MPI" in ([0-9]*) FOAM_MPI="impi-$FOAM_MPI";; esac case "$FOAM_MPI" in ([0-9]*) FOAM_MPI="impi-$FOAM_MPI";; esac
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using $WM_MPLIB" 1>&2 echo "Using $WM_MPLIB" 1>&2
echo " FOAM_MPI : $FOAM_MPI" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2
@ -283,7 +283,7 @@ INTELMPI)
# If subdirectory is version number only, prefix with 'impi-' # If subdirectory is version number only, prefix with 'impi-'
case "$FOAM_MPI" in ([0-9]*) FOAM_MPI="impi-$FOAM_MPI";; esac case "$FOAM_MPI" in ([0-9]*) FOAM_MPI="impi-$FOAM_MPI";; esac
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using $WM_MPLIB" 1>&2 echo "Using $WM_MPLIB" 1>&2
echo " FOAM_MPI : $FOAM_MPI" 1>&2 echo " FOAM_MPI : $FOAM_MPI" 1>&2

View File

@ -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" archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH # Clean PATH and LD_LIBRARY_PATH
eval $($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \ eval \
"$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-") "$($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 \ eval \
"$ParaView_DIR $archDir/ParaView- $archDir/qt-") "$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=LD_LIBRARY_PATH \
$ParaView_DIR $archDir/ParaView- $archDir/qt-)"
# ThirdParty cmake # ThirdParty cmake
cmake=$archDir/$cmake_version cmake="$archDir/$cmake_version"
if [ -r $cmake/bin/cmake ] if [ -r "$cmake/bin/cmake" ]
then then
# _foamAddPath not available when foamPV function is used # _foamAddPath not available when foamPV function is used
PATH=$cmake/bin:$PATH PATH="$cmake/bin:$PATH"
fi fi
# Evaluate command-line parameters for ParaView # Evaluate command-line parameters for ParaView
@ -159,7 +161,7 @@ then
;; ;;
esac esac
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using paraview" echo "Using paraview"
echo " ParaView_DIR : $ParaView_DIR" echo " ParaView_DIR : $ParaView_DIR"

View File

@ -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 # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using petsc ($petsc_version) -> $PETSC_ARCH_PATH" 1>&2 echo "Using petsc ($petsc_version) -> $PETSC_ARCH_PATH" 1>&2
fi fi

View File

@ -273,7 +273,7 @@ GCC_NOT_FOUND
_foamAddLibAuto $mpcDir _foamAddLibAuto $mpcDir
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using ThirdParty compiler" echo "Using ThirdParty compiler"
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})" echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})"
@ -299,7 +299,7 @@ CLANG_NOT_FOUND
_foamAddPath $clangDir/bin _foamAddPath $clangDir/bin
_foamAddLib $clangDir/lib # For things like libomp (openmp) etc _foamAddLib $clangDir/lib # For things like libomp (openmp) etc
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using ThirdParty compiler" echo "Using ThirdParty compiler"
echo " ${clangDir##*/}" echo " ${clangDir##*/}"

View File

@ -92,7 +92,7 @@ unset MPI_ARCH_PATH
unset MPI_BUFFER_SIZE unset MPI_BUFFER_SIZE
# Undefine OPAL_PREFIX if set to one of the paths on foamOldDirs # 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 then
unset OPAL_PREFIX unset OPAL_PREFIX
fi fi
@ -108,7 +108,7 @@ unset PV_PLUGIN_PATH
unset VTK_DIR unset VTK_DIR
# Undefine Qt5_DIR if set to one of the paths on foamOldDirs # 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 then
unset Qt5_DIR unset Qt5_DIR
fi fi
@ -137,9 +137,9 @@ unset SCOTCH_ARCH_PATH
if [ -n "$foamClean" ] if [ -n "$foamClean" ]
then then
eval $($foamClean -sh-env=PATH "$foamOldDirs") eval "$($foamClean -sh-env=PATH $foamOldDirs)"
eval $($foamClean -sh-env=LD_LIBRARY_PATH "$foamOldDirs") eval "$($foamClean -sh-env=LD_LIBRARY_PATH $foamOldDirs)"
eval $($foamClean -sh-env=MANPATH "$foamOldDirs") eval "$($foamClean -sh-env=MANPATH $foamOldDirs)"
fi fi
[ -n "$LD_LIBRARY_PATH" ] || unset LD_LIBRARY_PATH [ -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')" foamOldDirs="$(complete 2>/dev/null | sed -ne 's/^.*-F _of_.* \(..*\)$/\1/p')"
for cleaned in $foamOldDirs for cleaned in $foamOldDirs
do do
complete -r $cleaned 2>/dev/null complete -r "$cleaned" 2>/dev/null
done done
# Completion functions # Completion functions

View File

@ -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 # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ "$FOAM_VERBOSE" -a "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using vtk ($vtk_version) -> $VTK_DIR" 1>&2 echo "Using vtk ($vtk_version) -> $VTK_DIR" 1>&2
echo "Using mesa ($mesa_version) -> $MESA_ARCH_PATH" 1>&2 echo "Using mesa ($mesa_version) -> $MESA_ARCH_PATH" 1>&2