ENH: improve foamEtcFile handling (-prefix, -version options)

- This lets foamExec use foamEtcFile as well, but debian packaging
  still needs some work
This commit is contained in:
Mark Olesen
2010-07-06 14:01:15 +02:00
parent 266c4c61da
commit 9745b86ef3
2 changed files with 70 additions and 53 deletions

View File

@ -39,8 +39,6 @@
# @endverbatim
#
#-------------------------------------------------------------------------------
unset listOpt quietOpt
usage() {
[ "$quietOpt" = true ] && exit 1
@ -53,7 +51,11 @@ Usage: ${0##*/} [OPTION] fileName
options:
-list list the directories to be searched
-mode <mode> any combination of u(user), g(group), o(other)
-prefix <dir> specify an alternative installation prefix
(default: $WM_PROJECT_INST_DIR)
-quiet suppress all normal output
-version <ver> specify an alternative OpenFOAM version
(default: $WM_PROJECT_VERSION)
-help print the usage
Locate user/group/shipped file with semantics similar to the
@ -75,6 +77,13 @@ USAGE
# default mode is 'ugo'
mode=ugo
# default prefix/version correspond to the active values,
# but could also extract from the $0 value.
prefix="$WM_PROJECT_INST_DIR"
version="$WM_PROJECT_VERSION"
unset listOpt quietOpt
# parse options
while [ "$#" -gt 0 ]
do
@ -100,10 +109,20 @@ do
esac
shift 2
;;
-p | -prefix)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
prefix="$2"
shift 2
;;
-q | -quiet)
quietOpt=true
shift
;;
-v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version="$2"
shift 2
;;
-*)
usage "unknown option: '$*'"
;;
@ -121,21 +140,21 @@ fileName="$1"
unset dirList
case "$mode" in
*u*) # user
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$WM_PROJECT_VERSION"
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$version"
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}"
;;
esac
case "$mode" in
*g*) # group
dirList="$dirList $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION"
dirList="$dirList $WM_PROJECT_INST_DIR/site"
dirList="$dirList $prefix/site/$version"
dirList="$dirList $prefix/site"
;;
esac
case "$mode" in
*o*) # other
dirList="$dirList $WM_PROJECT_DIR/etc"
*o*) # other (shipped)
dirList="$dirList $prefix/${WM_PROJECT:-OpenFOAM}-$version/etc"
;;
esac
set -- $dirList