mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
CONFIG: address differences between shells
- suppress error messages that appear with zsh. According to unset(1p), 'unset -f' unsets a function. If the function was not previously defined, this is a no-op. This is similar for zsh, but there it emits a warning if the function was not previously defined. - avoid 'local' in functions sources from etc/bashrc. ksh does not support this. - use 'command' shell builtin instead of 'type'. Seems to be more consistent between shell flavours.
This commit is contained in:
@ -27,7 +27,7 @@
|
|||||||
# Description
|
# Description
|
||||||
# Set the environment for OpenFOAM when using a POSIX shell.
|
# Set the environment for OpenFOAM when using a POSIX shell.
|
||||||
# To be sourced manually or from the ~/.profile or ~/.bashrc files.
|
# To be sourced manually or from the ~/.profile or ~/.bashrc files.
|
||||||
# Should be usable by any POSIX-compliant shell (eg, dash, ksh)
|
# Should be usable by any POSIX-compliant shell (eg, bash,dash,zsh,...)
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -68,6 +68,6 @@ if ( "$ending" != "adios-none" && "$ending" != "adios-system" ) then
|
|||||||
_foamAddPath $ADIOS_ARCH_PATH/bin
|
_foamAddPath $ADIOS_ARCH_PATH/bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
unset adios_version ending cleaned
|
unset adios_version ending
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -167,8 +167,6 @@ if ( $?foamClean ) then
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
unset cleaned foamClean foamOldDirs
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Cleanup aliases
|
# Cleanup aliases
|
||||||
|
|
||||||
@ -198,5 +196,9 @@ unalias wmRefresh
|
|||||||
unalias foamVersion
|
unalias foamVersion
|
||||||
unalias foamPV
|
unalias foamPV
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Intermediate variables (do as last for a clean exit code)
|
||||||
|
|
||||||
|
unset cleaned foamClean foamOldDirs
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -58,7 +58,7 @@ then
|
|||||||
echo "Using adios ($adios_version) -> $ADIOS_ARCH_PATH" 1>&2
|
echo "Using adios ($adios_version) -> $ADIOS_ARCH_PATH" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type _foamAddPath > /dev/null 2>&1 # normal sourcing
|
if command -v _foamAddPath >/dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
# If ADIOS_ARCH_PATH does not end with '-system' or '-none',
|
# If ADIOS_ARCH_PATH does not end with '-system' or '-none',
|
||||||
# it is located within ThirdParty, or a central installation
|
# it is located within ThirdParty, or a central installation
|
||||||
@ -71,7 +71,7 @@ then
|
|||||||
_foamAddPath $ADIOS_ARCH_PATH/bin
|
_foamAddPath $ADIOS_ARCH_PATH/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset adios_version ending cleaned
|
unset adios_version ending
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ then
|
|||||||
echo "Using CGAL ($cgal_version) -> $CGAL_ARCH_PATH" 1>&2
|
echo "Using CGAL ($cgal_version) -> $CGAL_ARCH_PATH" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
|
|
||||||
# If BOOST_ARCH_PATH, CGAL_ARCH_PATH do not end with '-system' or '-none',
|
# If BOOST_ARCH_PATH, CGAL_ARCH_PATH do not end with '-system' or '-none',
|
||||||
|
|||||||
@ -58,7 +58,7 @@ then
|
|||||||
echo "Using fftw ($fftw_version) -> $FFTW_ARCH_PATH" 1>&2
|
echo "Using fftw ($fftw_version) -> $FFTW_ARCH_PATH" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
|
|
||||||
# If FFTW_ARCH_PATH does not end with '-system' or '-none',
|
# If FFTW_ARCH_PATH does not end with '-system' or '-none',
|
||||||
|
|||||||
@ -69,7 +69,7 @@ alias run='cd $FOAM_RUN'
|
|||||||
|
|
||||||
# Refresh the environment
|
# Refresh the environment
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
unset -f wmRefresh
|
unset -f wmRefresh 2>/dev/null
|
||||||
wmRefresh()
|
wmRefresh()
|
||||||
{
|
{
|
||||||
wmProjectDir=$WM_PROJECT_DIR
|
wmProjectDir=$WM_PROJECT_DIR
|
||||||
@ -81,7 +81,7 @@ wmRefresh()
|
|||||||
|
|
||||||
# Change OpenFOAM version
|
# Change OpenFOAM version
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
unset -f foamVersion
|
unset -f foamVersion 2>/dev/null
|
||||||
foamVersion()
|
foamVersion()
|
||||||
{
|
{
|
||||||
if [ "$1" ]; then
|
if [ "$1" ]; then
|
||||||
@ -98,7 +98,7 @@ foamVersion()
|
|||||||
|
|
||||||
# Change ParaView version
|
# Change ParaView version
|
||||||
# ~~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
unset -f foamPV
|
unset -f foamPV 2>/dev/null
|
||||||
foamPV()
|
foamPV()
|
||||||
{
|
{
|
||||||
. $WM_PROJECT_DIR/etc/config.sh/paraview "${@+ParaView_VERSION=$1}"
|
. $WM_PROJECT_DIR/etc/config.sh/paraview "${@+ParaView_VERSION=$1}"
|
||||||
|
|||||||
@ -56,15 +56,13 @@ then
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Source an etc file, possibly with some verbosity
|
# Source an etc file, possibly with some verbosity
|
||||||
_foamEtc()
|
# - use eval to avoid intermediate variables (ksh doesn't have 'local')
|
||||||
{
|
if [ "$FOAM_VERBOSE" -a "$PS1" ]
|
||||||
local file
|
|
||||||
if [ $# -gt 0 ] && file=$($WM_PROJECT_DIR/bin/foamEtcFile "$@")
|
|
||||||
then
|
then
|
||||||
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $file" 1>&2
|
_foamEtc(){ eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh-verbose $@)"; }
|
||||||
. $file
|
else
|
||||||
|
_foamEtc(){ eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh $@)"; }
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
# Evaluate command-line parameters
|
# Evaluate command-line parameters
|
||||||
_foamEval()
|
_foamEval()
|
||||||
@ -104,9 +102,9 @@ then
|
|||||||
else
|
else
|
||||||
# Was previously loaded/defined - now unset
|
# Was previously loaded/defined - now unset
|
||||||
|
|
||||||
|
unset -f _foamAddPath _foamAddLib _foamAddMan 2>/dev/null
|
||||||
|
unset -f _foamEtc _foamEval 2>/dev/null
|
||||||
unset WM_SHELL_FUNCTIONS
|
unset WM_SHELL_FUNCTIONS
|
||||||
unset -f _foamAddPath _foamAddLib _foamAddMan
|
|
||||||
unset -f _foamEtc _foamEval
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ then
|
|||||||
echo "Using gperftools ($gperftools_version) -> $GPERFTOOLS_ARCH_PATH" 1>&2
|
echo "Using gperftools ($gperftools_version) -> $GPERFTOOLS_ARCH_PATH" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
|
|
||||||
# If GPERFTOOLS_ARCH_PATH does not end with '-system' or '-none',
|
# If GPERFTOOLS_ARCH_PATH does not end with '-system' or '-none',
|
||||||
|
|||||||
@ -71,7 +71,7 @@ OPENMPI)
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Could be sourced from ThirdParty with incomplete environment
|
# Could be sourced from ThirdParty with incomplete environment
|
||||||
if type _foamAddLib > /dev/null 2>&1
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
_foamAddPath $MPI_ARCH_PATH/bin
|
_foamAddPath $MPI_ARCH_PATH/bin
|
||||||
_foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
_foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
||||||
@ -140,7 +140,7 @@ MPICH)
|
|||||||
export MPI_HOME=$MPI_ARCH_PATH
|
export MPI_HOME=$MPI_ARCH_PATH
|
||||||
|
|
||||||
# Could be sourced from ThirdParty with incomplete environment
|
# Could be sourced from ThirdParty with incomplete environment
|
||||||
if type _foamAddLib > /dev/null 2>&1
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
_foamAddPath $MPI_ARCH_PATH/bin
|
_foamAddPath $MPI_ARCH_PATH/bin
|
||||||
_foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
_foamAddLib $MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
||||||
|
|||||||
@ -173,7 +173,7 @@ unset -f _foamParaviewEval
|
|||||||
unset cleaned cmake cmake_version pvName pvMajor pvLibDir pvPython
|
unset cleaned cmake cmake_version pvName pvMajor pvLibDir pvPython
|
||||||
unset ParaView_MAJOR
|
unset ParaView_MAJOR
|
||||||
|
|
||||||
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
unset ParaView_VERSION
|
unset ParaView_VERSION
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -148,13 +148,9 @@ then
|
|||||||
cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned"
|
cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
[ -n "$LD_LIBRARY_PATH" ] || unset LD_LIBRARY_PATH
|
[ -n "$LD_LIBRARY_PATH" ] || unset LD_LIBRARY_PATH
|
||||||
[ -n "$MANPATH" ] || unset MANPATH
|
|
||||||
[ -n "$LD_PRELOAD" ] || unset LD_PRELOAD
|
[ -n "$LD_PRELOAD" ] || unset LD_PRELOAD
|
||||||
|
[ -n "$MANPATH" ] || unset MANPATH
|
||||||
unset cleaned foamClean foamOldDirs
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Cleanup aliases and functions
|
# Cleanup aliases and functions
|
||||||
@ -181,9 +177,13 @@ unalias util 2>/dev/null
|
|||||||
unalias tut 2>/dev/null
|
unalias tut 2>/dev/null
|
||||||
unalias run 2>/dev/null
|
unalias run 2>/dev/null
|
||||||
|
|
||||||
unset -f wmRefresh
|
unset -f wmRefresh 2>/dev/null
|
||||||
unset -f foamVersion
|
unset -f foamVersion 2>/dev/null
|
||||||
unset -f foamPV
|
unset -f foamPV 2>/dev/null
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Intermediate variables (do as last for a clean exit code)
|
||||||
|
|
||||||
|
unset cleaned foamClean foamOldDirs
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -57,7 +57,7 @@ then
|
|||||||
echo "Using mesa ($mesa_version) -> $MESA_ARCH_PATH" 1>&2
|
echo "Using mesa ($mesa_version) -> $MESA_ARCH_PATH" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type _foamAddLib > /dev/null 2>&1 # normal sourcing
|
if command -v _foamAddLib > /dev/null 2>&1 # normal sourcing
|
||||||
then
|
then
|
||||||
|
|
||||||
# Set paths if binaries are present
|
# Set paths if binaries are present
|
||||||
|
|||||||
@ -145,7 +145,7 @@ endif
|
|||||||
# ~~~~~~~~~~~~~~~~~~~~~~
|
# ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
||||||
|
|
||||||
# Source etc files, possibly with some verbosity
|
# Source an etc file, possibly with some verbosity
|
||||||
if ($?FOAM_VERBOSE && $?prompt) then
|
if ($?FOAM_VERBOSE && $?prompt) then
|
||||||
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`'
|
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`'
|
||||||
else
|
else
|
||||||
|
|||||||
@ -158,7 +158,7 @@ canBuildPlugin()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
type cmake > /dev/null 2>&1 || {
|
command -v cmake > /dev/null 2>&1 || {
|
||||||
echo "==> cannot build ParaView plugins without cmake"
|
echo "==> cannot build ParaView plugins without cmake"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user