mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: foamExec mangled the arguments
- use function when sourcing the bashrc to avoid these problems
This commit is contained in:
43
bin/foamExec
43
bin/foamExec
@ -3,7 +3,7 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
||||
# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# License
|
||||
@ -59,10 +59,10 @@ USAGE
|
||||
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
||||
#
|
||||
# foamEtcFile is found in the same directory
|
||||
# foamEtcFile must be found in the same directory as this script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
unset etcOpts
|
||||
unset etcOpts version
|
||||
# parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
@ -72,7 +72,13 @@ do
|
||||
;;
|
||||
-v | -version)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
etcOpts="-version $2"
|
||||
version="$2"
|
||||
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
||||
shift
|
||||
;;
|
||||
-m | -mode | -p | -prefix)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
etcOpts="$etcOpts $1 $2" # pass-thru to foamEtcFile
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
@ -89,19 +95,28 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$#" -ge 1 ] || usage "no application specified"
|
||||
|
||||
# find OpenFOAM settings (bashrc)
|
||||
foamDotFile="$(${0%/*}/foamEtcFile $etcOpts bashrc)" || {
|
||||
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
|
||||
exit 1
|
||||
#
|
||||
# Find and source OpenFOAM settings (bashrc)
|
||||
# placed in function to preserve command-line arguments
|
||||
#
|
||||
sourceRc()
|
||||
{
|
||||
# default is the current version
|
||||
: ${version:=${WM_PROJECT_VERSION:-unknown}}
|
||||
|
||||
foamDotFile="$(${0%/*}/foamEtcFile $etcOpts bashrc)" || {
|
||||
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
. $foamDotFile
|
||||
}
|
||||
|
||||
# preserve arguments (can otherwise get lost when sourcing the foamDotFile)
|
||||
args="$*"
|
||||
. $foamDotFile
|
||||
|
||||
# execute
|
||||
exec $args
|
||||
[ "$#" -ge 1 ] || usage "no application specified"
|
||||
|
||||
sourceRc
|
||||
exec "$@"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user