#----------------------------------*-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 . # # File # etc/config.sh/functions # # Description # Initialization script functions for the bashrc environment # Sourced from OpenFOAM-/etc/config.sh/bashrc # #------------------------------------------------------------------------------ if [ -z "$WM_BASH_FUNCTIONS" ] then # Temporary environment variable for automatically (un)loading functions WM_BASH_FUNCTIONS=loaded # Source a file, possibly with some verbosity _foamSource() { if [ $# -gt 0 -a -f "$1" ] then [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2 . $1 fi } # Source an etc file, possibly with some verbosity _foamSourceEtc() { 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 -*) # 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" ;; *) # Filename: source it if [ -f "$1" ] then [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2 . "$1" else _foamSourceEtc -silent "$1" fi ;; esac shift done } # 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 } else # Cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ unset WM_BASH_FUNCTIONS unset -f _foamAddPath _foamAddLib _foamAddMan unset -f _foamSourceEtc _foamEval unset -f _foamSource fi #------------------------------------------------------------------------------