From 0f58ac5a9b91a3eca082fac711d09f8e909b78f3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 12 Apr 2010 11:12:51 +0200 Subject: [PATCH] ENH: abort if rsync is missing - foamCopySettings, foamNewCase --- bin/foamCopySettings | 31 ++++++++++++++++++++++++++++--- bin/foamNewCase | 10 ++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/bin/foamCopySettings b/bin/foamCopySettings index cfa9d901e4..9e1969c96b 100755 --- a/bin/foamCopySettings +++ b/bin/foamCopySettings @@ -37,9 +37,12 @@ # to add any custom rsync options. #------------------------------------------------------------------------------- Script=${0##*/} -if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -ne 2 ] -then + +#------------------------------------------------------------------------------ +usage() { + while [ "$#" -ge 1 ]; do echo "$1" 1>&2; shift; done cat <&2 + Usage: $Script srcDir dstDir Copy OpenFOAM settings from one case to another, without copying @@ -52,7 +55,29 @@ Note USAGE 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%/} dstDir=${2%/} diff --git a/bin/foamNewCase b/bin/foamNewCase index 6d83d5c5dd..52cd516bb6 100755 --- a/bin/foamNewCase +++ b/bin/foamNewCase @@ -55,7 +55,6 @@ USAGE exit 1 } #------------------------------------------------------------------------------ - unset appName caseName listOpt # parse options @@ -84,12 +83,19 @@ do version="$2" shift 2 ;; + -*) + usage "unknown option: '$*'" + ;; *) - usage "unknown option/argument: '$*'" + usage "unexpected argument: '$*'" ;; esac done +# need rsync, except for when listing +type rsync >/dev/null 2>&1 || [ "$listOpt" = true ] || usage "Error: 'rsync' seems to be missing" + + #------------------------------------------------------------------------------ [ -n "$version" ] || {