Replace shell-based auto-detection with a singe Python-oneliner that should be more stable (at least it doesn't choke on symbolic links anymore)

--HG--
branch : bgschaid/minorAdditionsBranch
This commit is contained in:
Bernhard F.W. Gschaider 2013-09-04 23:47:55 +02:00
parent 0a1adf26a8
commit af4c60ef56
2 changed files with 3 additions and 50 deletions

View file

@ -46,34 +46,7 @@ export WM_PROJECT_VERSION=1.6-ext
if [ -z "$WM_PROJECT_VERSION_ADDITION" ]
then
fullScriptPath=`pwd`"/$0"
if [ ! -e $fullScriptPath ]
then
fullScriptPath=$0
fi
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
export WM_PROJECT_VERSION_ADDITION=`python -c "from os.path import *;print abspath(join(curdir,'$0')).split(sep)[-3][len('OpenFOAM-$WM_PROJECT_VERSION')+1:]"`
fi
if [ -n "$WM_PROJECT_VERSION_ADDITION" ]

View file

@ -47,28 +47,8 @@ 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
setenv WM_PROJECT_VERSION_ADDITION `python -c "from os.path import *;print abspath(join(curdir,'$called[2]')).split(sep)[-3][len('OpenFOAM-$WM_PROJECT_VERSION')+1:]"`
unset called
endif
unset prefSettingFile called