mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
CONFIG: inline _foamEval within <etc/config.sh/setup>
- previously a function (unlike the csh version) but since bashrc and setup have been split -> replace with inline definition STYLE: formatting/wording for openfoam starters TUT: simplify controlDict modification, add default substitution ENH: accept '/' for end-of-options terminator (etc/openfoam) - makes the application or service more apparent. * eg. /usr/bin/openfoam / blockMesh * vs. /usr/bin/openfoam -- blockMesh Accept lone '-' as the end-of-options terminator, as per bash - Adjust handling of openfoam '-c' option to flag that a command-string will appear, but continue with option parsing. Consistent with bash definition.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -159,45 +159,6 @@ then
|
||||
fi
|
||||
|
||||
|
||||
# Evaluate command-line parameters
|
||||
unset -f _foamEval 2>/dev/null
|
||||
_foamEval()
|
||||
{
|
||||
for i
|
||||
do
|
||||
case "$i" in
|
||||
-*)
|
||||
# Stray option (not meant for us here) -> get out
|
||||
break
|
||||
;;
|
||||
*=)
|
||||
# name= -> unset name
|
||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||
&& echo "unset ${1%=}" 1>&2
|
||||
eval "unset ${1%=}"
|
||||
;;
|
||||
*=*)
|
||||
# name=value -> export name=value
|
||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||
&& echo "export $i" 1>&2
|
||||
eval "export $i"
|
||||
;;
|
||||
*)
|
||||
# Filename: source it
|
||||
if [ -f "$i" ]
|
||||
then
|
||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||
&& echo "Using: $i" 1>&2
|
||||
. "$i"
|
||||
else
|
||||
_foamEtc -silent "$i"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Avoid any ThirdParty settings that may have 'leaked' into the environment
|
||||
|
||||
@ -221,7 +182,7 @@ else
|
||||
# Was previously loaded/defined - now unset
|
||||
|
||||
unset -f _foamAddPath _foamAddMan _foamAddLib _foamAddLibAuto 2>/dev/null
|
||||
unset -f _foamClean _foamEcho _foamEtc _foamEval 2>/dev/null
|
||||
unset -f _foamClean _foamEcho _foamEtc 2>/dev/null
|
||||
unset foamClean
|
||||
unset WM_SHELL_FUNCTIONS
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -106,19 +106,64 @@ then
|
||||
fi
|
||||
|
||||
|
||||
# Capture and evaluate any command-line parameters
|
||||
# These can be used to set/unset values, specify additional files etc.
|
||||
FOAM_SETTINGS="$@"
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Evaluate the command-line parameters, which were saved as FOAM_SETTINGS.
|
||||
# These can be used to set/unset values, specify additional files etc.
|
||||
if [ -z "$FOAM_SETTINGS" ]
|
||||
# Capture and evaluate command-line parameters
|
||||
# - set/unset values, specify additional files etc.
|
||||
# - parameters never start with '-'
|
||||
if [ "$#" -gt 0 ] && [ "${1#-}" = "${1}" ]
|
||||
then
|
||||
unset FOAM_SETTINGS
|
||||
FOAM_SETTINGS="$@"
|
||||
if [ -n "$FOAM_SETTINGS" ]
|
||||
then
|
||||
export FOAM_SETTINGS
|
||||
|
||||
for foamVar_eval
|
||||
do
|
||||
case "$foamVar_eval" in
|
||||
(-*)
|
||||
# Stray option (not meant for us here) -> get out
|
||||
break
|
||||
;;
|
||||
(=*)
|
||||
# Junk
|
||||
;;
|
||||
(*=)
|
||||
# name= -> unset name
|
||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||
&& echo "unset ${foamVar_eval%=}" 1>&2
|
||||
eval "unset ${foamVar_eval%=}"
|
||||
;;
|
||||
(*=*)
|
||||
# name=value -> export name=value
|
||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||
&& echo "export $foamVar_eval" 1>&2
|
||||
eval "export $foamVar_eval"
|
||||
;;
|
||||
(*)
|
||||
# Filename: source it
|
||||
if [ -f "$foamVar_eval" ]
|
||||
then
|
||||
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
|
||||
&& echo "Using: $foamVar_eval" 1>&2
|
||||
. "$foamVar_eval"
|
||||
elif [ -n "$foamVar_eval" ]
|
||||
then
|
||||
_foamEtc -silent "$foamVar_eval"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
unset FOAM_SETTINGS
|
||||
fi
|
||||
else
|
||||
export FOAM_SETTINGS
|
||||
_foamEval "$@"
|
||||
unset FOAM_SETTINGS
|
||||
fi
|
||||
unset foamVar_eval
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# Verify FOAM_CONFIG_ETC (from calling environment or from prefs)
|
||||
if [ -n "$FOAM_CONFIG_ETC" ]
|
||||
|
||||
Reference in New Issue
Block a user