Newer
Older
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# File
# etc/config.sh/functions
#
# Description
# Initialization script functions for the bashrc environment
# Sourced from OpenFOAM-<VERSION>/etc/config.sh/bashrc
#
#------------------------------------------------------------------------------
if [ -z "$WM_BASH_FUNCTIONS" ]
then
# Not previously loaded/defined - define now
# Temporary environment variable to track loading/unloading of functions
WM_BASH_FUNCTIONS=loaded
# Prefix to PATH
_foamAddPath()
[ $# -gt 0 ] && export PATH=$1:$PATH
}
# Prefix to LD_LIBRARY_PATH
_foamAddLib()
{
[ $# -gt 0 ] && export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
}
# Prefix to MANPATH
_foamAddMan()
{
[ $# -gt 0 ] && export MANPATH=$1:$MANPATH
}
# Source an etc file, possibly with some verbosity
{
local file
if [ $# -gt 0 ] && file=$($WM_PROJECT_DIR/bin/foamEtcFile "$@")
then
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $file" 1>&2
. $file
fi
}
# Evaluate command-line parameters
_foamEval()
{
local file
while [ $# -gt 0 ]
do
case "$1" in
-*)
Henry Weller
committed
# Stray option (not meant for us here) -> get out
break
;;
*=)
# name= -> unset name
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "unset ${1%=}" 1>&2
eval "unset ${1%=}"
;;
*=*)
# name=value -> export name=value
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "export $1" 1>&2
eval "export $1"
;;
*)
Henry Weller
committed
# Filename: source it
if [ -f "$1" ]
then
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2
. "$1"
fi
;;
esac
shift
done
}
else
# Was previously loaded/defined - now unset
unset WM_BASH_FUNCTIONS
unset -f _foamAddPath _foamAddLib _foamAddMan
unset -f _foamEtc _foamEval
#------------------------------------------------------------------------------