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:
35
bin/foamExec
35
bin/foamExec
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
# \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -59,10 +59,10 @@ USAGE
|
|||||||
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
|
||||||
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
|
# 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
|
# parse options
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -72,7 +72,13 @@ do
|
|||||||
;;
|
;;
|
||||||
-v | -version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -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
|
shift
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
@ -89,19 +95,28 @@ do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "$#" -ge 1 ] || usage "no application specified"
|
|
||||||
|
|
||||||
# find OpenFOAM settings (bashrc)
|
#
|
||||||
|
# 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)" || {
|
foamDotFile="$(${0%/*}/foamEtcFile $etcOpts bashrc)" || {
|
||||||
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
|
echo "Error : bashrc file could not be found for OpenFOAM-$version" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# preserve arguments (can otherwise get lost when sourcing the foamDotFile)
|
|
||||||
args="$*"
|
|
||||||
. $foamDotFile
|
. $foamDotFile
|
||||||
|
}
|
||||||
|
|
||||||
# execute
|
|
||||||
exec $args
|
[ "$#" -ge 1 ] || usage "no application specified"
|
||||||
|
|
||||||
|
sourceRc
|
||||||
|
exec "$@"
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user