Commit 4c14bc66 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: foamVersion alias should not change directory (closes #1131)

parent b0eeea83
......@@ -60,10 +60,11 @@ alias uutil 'cd $WM_PROJECT_USER_DIR/applications/utilities'
alias wmRefresh 'set projectDir=$WM_PROJECT_DIR; set foamSettings=$FOAM_SETTINGS; wmUnset; source $projectDir/etc/cshrc $foamSettings'
# Change OpenFOAM version
# ~~~~~~~~~~~~~~~~~~~~~~~
# Query the current OpenFOAM version
# or change to another version (if installed in a parallel directory)
# - can be fragile
alias foamVersion \
'if ( "\!*" != "" ) source ${WM_PROJECT_DIR:h}/OpenFOAM-\!*/etc/cshrc; foam; echo OpenFOAM-$WM_PROJECT_VERSION'
'if ( "\!*" != "" ) source ${WM_PROJECT_DIR:h}/OpenFOAM-\!*/etc/cshrc; echo OpenFOAM-$WM_PROJECT_VERSION'
# Change ParaView version
......
......@@ -60,7 +60,7 @@ wmRefresh()
{
local projectDir="$WM_PROJECT_DIR"
local foamSettings="$FOAM_SETTINGS"
wmUnset
. "$projectDir/etc/config.sh/unset" 2>/dev/null
. "$projectDir/etc/bashrc" "$foamSettings"
}
......@@ -70,20 +70,19 @@ wmRefresh()
unset -f foamVersion 2>/dev/null
foamVersion()
{
if [ "$#" -gt 0 ]
if [ "$#" -gt 0 ] && [ -d "$WM_PROJECT_DIR" ]
then
local dir="${WM_PROJECT_DIR%/*}" # Parent directory
local prefixDir="${WM_PROJECT_DIR%/*}" # Parent directory
local ver="$1"
shift
if [ -f "$dir/OpenFOAM-$ver/etc/bashrc" ]
if [ -f "$prefixDir/OpenFOAM-$ver/etc/bashrc" ]
then
wmUnset
. "$dir/OpenFOAM-$ver/etc/bashrc"
foam
echo "Changed to OpenFOAM-$WM_PROJECT_VERSION" 1>&2
. "$WM_PROJECT_DIR/etc/config.sh/unset" 2>/dev/null
. "$prefixDir/OpenFOAM-$ver/etc/bashrc"
echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2
else
echo "No OpenFOAM-$ver available in $dir" 1>&2
echo "No OpenFOAM-$ver available in $prefixDir" 1>&2
echo "Using OpenFOAM-$WM_PROJECT_VERSION" 1>&2
return 1
fi
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment