ENH: abort if rsync is missing - foamCopySettings, foamNewCase

This commit is contained in:
Mark Olesen 2010-04-12 11:12:51 +02:00
parent 1aa25ebf39
commit 0f58ac5a9b
2 changed files with 36 additions and 5 deletions

View File

@ -37,9 +37,12 @@
# to add any custom rsync options. # to add any custom rsync options.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
Script=${0##*/} Script=${0##*/}
if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -ne 2 ]
then #------------------------------------------------------------------------------
usage() {
while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done
cat <<USAGE 1>&2 cat <<USAGE 1>&2
Usage: $Script srcDir dstDir Usage: $Script srcDir dstDir
Copy OpenFOAM settings from one case to another, without copying Copy OpenFOAM settings from one case to another, without copying
@ -52,7 +55,29 @@ Note
USAGE USAGE
exit 1 exit 1
fi }
#------------------------------------------------------------------------------
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-*)
usage "unknown option: '$*'"
;;
*)
break
;;
esac
done
# need rsync
type rsync >/dev/null 2>&1 || usage "Error: 'rsync' seems to be missing"
[ "$#" -eq 2 ] || usage "Error: incorrect number of arguments"
srcDir=${1%/} srcDir=${1%/}
dstDir=${2%/} dstDir=${2%/}

View File

@ -55,7 +55,6 @@ USAGE
exit 1 exit 1
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset appName caseName listOpt unset appName caseName listOpt
# parse options # parse options
@ -84,12 +83,19 @@ do
version="$2" version="$2"
shift 2 shift 2
;; ;;
-*)
usage "unknown option: '$*'"
;;
*) *)
usage "unknown option/argument: '$*'" usage "unexpected argument: '$*'"
;; ;;
esac esac
done done
# need rsync, except for when listing
type rsync >/dev/null 2>&1 || [ "$listOpt" = true ] || usage "Error: 'rsync' seems to be missing"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
[ -n "$version" ] || { [ -n "$version" ] || {