diff --git a/etc/bashrc b/etc/bashrc index d585fc90a..8365dabeb 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -43,6 +43,35 @@ unset prefSettingFile export WM_PROJECT=OpenFOAM export WM_PROJECT_VERSION=1.6-ext + +if [ -z "$WM_PROJECT_VERSION_ADDITION" ] +then + fullScriptPath=`pwd`"/$0" + canonicalFullScriptPath="$(readlink 2>&1 -f $fullScriptPath)" + if [ $? != 0 ] + then + # System with simpler readlink (BSD, Darwin) try replacement + canonicalFullScriptPath="$(greadlink 2>&1 -f $fullScriptPath)" + if [ $? != 0 ] + then + # we give up + canonicalFullScriptPath="" + fi + fi + + if [ -n "$canonicalFullScriptPath" ] + then + dirName="$(basename $(dirname $(dirname $canonicalFullScriptPath)))" + rest="$(echo $dirName | sed -e "s/OpenFOAM-$WM_PROJECT_VERSION//")" + if [ -n $rest ] + then + export WM_PROJECT_VERSION_ADDITION="$(echo $rest | sed -e "s/-//")" + fi + unset dirName rest + fi + unset fullScriptPath canonicalFullScriptPath +fi + if [ -n "$WM_PROJECT_VERSION_ADDITION" ] then export WM_PROJECT_VERSION=$WM_PROJECT_VERSION-$WM_PROJECT_VERSION_ADDITION diff --git a/etc/cshrc b/etc/cshrc index 9cdb7b1bf..7cabf0abf 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -42,11 +42,36 @@ if ( -r $prefSettingFile ) then # echo "Found presettings $prefSettingFile" source $prefSettingFile endif -unset prefSettingFile,called setenv WM_PROJECT OpenFOAM setenv WM_PROJECT_VERSION 1.6-ext +if( ! $?WM_PROJECT_VERSION_ADDITION ) then + set fullScriptPath = `pwd`"/$called[2]" + set canonicalFullScriptPath = `readlink -f $fullScriptPath |& cat` + if( $? != 0 ) then + # System with simpler readlink (BSD, Darwin) try replacement + set canonicalFullScriptPath=`greadlink -f $fullScriptPath |& cat` + if ( $? != 0 ) then + # we give up + set canonicalFullScriptPath="" + endif + endif + + if ( "$canonicalFullScriptPath" != "" ) then + set pathHere=`dirname $canonicalFullScriptPath` + set pathHere=`dirname $pathHere` + set dirName=`basename $pathHere` + set rest=`echo $dirName | sed -e "s/OpenFOAM-$WM_PROJECT_VERSION//"` + if ( "$rest" != "" ) then + setenv WM_PROJECT_VERSION_ADDITION `echo $rest | sed -e "s/-//"` + endif + unset dirName pathHere rest + endif + unset fullScriptPath canonicalFullScriptPath +endif +unset prefSettingFile called + if ( $?WM_PROJECT_VERSION_ADDITION ) then setenv WM_PROJECT_VERSION $WM_PROJECT_VERSION-$WM_PROJECT_VERSION_ADDITION endif