diff --git a/wmake/wclean b/wmake/wclean index a2161a88c..f615a9906 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -39,15 +39,20 @@ Script=${0##*/} # Source the wmake functions . ${0%/*}/scripts/wmakeFunctions -usage() { +error() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} + +usage() { cat<&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} + +usage() { cat< [ ... ] @@ -67,7 +72,6 @@ Usage: $Script [ -current | -all ] are deleted. USAGE - exit 1 } # Print help message @@ -77,7 +81,7 @@ fi # Check the script is executed from the project top-level directory [ "$PWD" = "$WM_PROJECT_DIR" ] || \ - usage "Not in the project top-level directory " $WM_PROJECT_DIR + error "Not in the project top-level directory " $WM_PROJECT_DIR # Get the platforms from the arguments platforms="$@" @@ -121,7 +125,7 @@ fi # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script platforms +unset Script platforms error usage #------------------------------------------------------------------------------ diff --git a/wmake/wdep b/wmake/wdep index 916ef72cb..a4d56dbb5 100755 --- a/wmake/wdep +++ b/wmake/wdep @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -41,19 +41,24 @@ Script=${0##*/} . ${0%/*}/scripts/wmakeFunctions usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< +options: + -help Print the usage Find the dep-file corresponding to in the current directory and print the path. USAGE - exit 1 } +error() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} #------------------------------------------------------------------------------ # Parse arguments and options @@ -63,10 +68,10 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) - usage + usage && exit 0 ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -112,7 +117,7 @@ echo $objectsDir/$fileName.dep # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage error #------------------------------------------------------------------------------ diff --git a/wmake/wmake b/wmake/wmake index 38564f258..b43e22653 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -58,25 +58,30 @@ Script=${0##*/} # Source the wmake functions . ${0%/*}/scripts/wmakeFunctions -usage() { +error() { exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} + +usage() { cat< | -j Compile using N cores/hyperthreads -no-scheduler Compile without wmakeScheduler -update Update lnInclude directories, dep files, remove deprecated files and directories - -h | -help Print the usage + -help | -h Print the usage A general, easy-to-use make system for multi-platform development @@ -97,7 +102,6 @@ or a special target: objects Compile but not link USAGE - exit 1 } @@ -135,7 +139,7 @@ do case "$1" in # Print help -h | -help) - usage + usage && exit 0 ;; -s | -silent) export WM_QUIET=1 @@ -181,7 +185,7 @@ do break ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -470,7 +474,7 @@ exec $make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \ # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage useAllCores update expandPath findTarget +unset Script usage error useAllCores update expandPath findTarget #------------------------------------------------------------------------------ diff --git a/wmake/wmakeCheckPwd b/wmake/wmakeCheckPwd index 726b0038f..ce24cd2fb 100755 --- a/wmake/wmakeCheckPwd +++ b/wmake/wmakeCheckPwd @@ -37,15 +37,13 @@ Script=${0##*/} unset quietOpt usage() { - [ "$quietOpt" = true ] && exit 1 - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< @@ -53,6 +51,13 @@ options: Exit status 1 on error USAGE +} + +error() { + [ "$quietOpt" = true ] && exit 1 + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage exit 1 } @@ -65,14 +70,14 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) - usage + usage && exit 0 ;; -q | -quiet) quietOpt=true shift ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -81,7 +86,7 @@ do done -[ "$#" -eq 1 ] || usage +[ "$#" -eq 1 ] || error # Set dirName to dirName="$1" @@ -115,7 +120,7 @@ exit 1 # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage error #------------------------------------------------------------------------------ diff --git a/wmake/wmakeCollect b/wmake/wmakeCollect index 2aaa2c6ee..fd4ed3442 100755 --- a/wmake/wmakeCollect +++ b/wmake/wmakeCollect @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -35,8 +35,6 @@ Script=${0##*/} usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< @@ -44,7 +42,7 @@ Usage: $Script [OPTION] options: -clean Clean-up before compilation (removes old makefiles) -kill Clean-up after termination (removes makefiles) - -h | -help Print the usage + -help | -h Print the usage Collecting scheduler for fast parallel compilation of large numbers of object files. Can be used in compiling OpenFOAM by setting the WM_SCHEDULER variable. @@ -65,6 +63,12 @@ Typical usage for compiling OpenFOAM: wmake -queue or wmake -q USAGE +} + +error() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage exit 1 } @@ -75,14 +79,14 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) - usage + usage && exit 0 ;; -kill | -clean) cleanup="true" shift ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" break ;; *) @@ -166,7 +170,7 @@ fi # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage error #------------------------------------------------------------------------------ diff --git a/wmake/wmakeFilesAndOptions b/wmake/wmakeFilesAndOptions index 488c211ab..fa9ef9cb6 100755 --- a/wmake/wmakeFilesAndOptions +++ b/wmake/wmakeFilesAndOptions @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -36,18 +36,23 @@ Script=${0##*/} usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< into /lnInclude @@ -59,9 +57,14 @@ Note and changes the default linking from 'ln -s' to 'ln -sf'. USAGE - exit 1 } +error() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} #------------------------------------------------------------------------------ # Parse arguments and options @@ -79,7 +82,7 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) # Provide immediate help - usage + usage && exit 0 ;; -u | -update) update=true @@ -91,7 +94,7 @@ do shift ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -103,7 +106,7 @@ if [ $# -eq 1 ] then baseDir=$1 else - usage "Error: incorrect number of arguments" + error "Error: incorrect number of arguments" fi @@ -172,7 +175,7 @@ find .. $findOpt \ # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage error #------------------------------------------------------------------------------ diff --git a/wmake/wmakeLnIncludeAll b/wmake/wmakeLnIncludeAll index 73cd5798c..ba4927b3b 100755 --- a/wmake/wmakeLnIncludeAll +++ b/wmake/wmakeLnIncludeAll @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -36,20 +36,24 @@ Script=${0##*/} usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< | -j Compile using N cores/hyperthreads + -help | -h Print the usage Find directories with a 'Make/files' that contains a 'LIB =' directive and execute 'wmakeLnInclude -update' for each one USAGE +} + +error() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage exit 1 } @@ -68,7 +72,7 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) # Provide immediate help - usage + usage && exit 0 ;; -u | -update) wmLnOpt="-update" @@ -84,7 +88,7 @@ do nCores=${1#-j} ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -164,7 +168,7 @@ fi # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage error #------------------------------------------------------------------------------ diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index 39a8f3be0..72494b47d 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -35,19 +35,17 @@ Script=${0##*/} usage() { - exec 1>&2 - - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< specify packager/release tag ('none' marks an empty packager) -short report short version information (ie, without pkg tag) - -version VER specify an alternative version + -version specify an alternative version Print the version used when building the project, in this order of precedence: * the git head commit (prefixed with \$WM_PROJECT_VERSION) @@ -55,9 +53,14 @@ Print the version used when building the project, in this order of precedence: * \$WM_PROJECT_VERSION USAGE - exit 1 } +error() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} #------------------------------------------------------------------------------ # Parse arguments and options @@ -68,7 +71,7 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) - usage + usage && exit 0 ;; -c | -check) checkOnly=true @@ -83,7 +86,7 @@ do shift ;; -pkg | -package) - [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + [ "$#" -ge 2 ] || error "'$1' option requires an argument" # Mark empty as 'none', disallow '!' in string package=$(echo "${2:-none}" | sed -e 's/!//g') shift 2 @@ -93,12 +96,12 @@ do shift ;; -v | -version) - [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + [ "$#" -ge 2 ] || error "'$1' option requires an argument" version="$2" shift 2 ;; *) - usage "unknown option/argument: '$*'" + error "unknown option/argument: '$*'" ;; esac done diff --git a/wmake/wrmdep b/wmake/wrmdep index 790d6ed90..802fb063e 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -84,9 +84,14 @@ Usage: Must be executed in the project top-level directory: $WM_PROJECT_DIR USAGE - exit 1 } +error() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} #------------------------------------------------------------------------------ # Parse arguments and options @@ -103,7 +108,7 @@ do case "$1" in # Print help -h | -help) - usage + usage && exit 0 ;; # Non-stop compilation, ignoring errors -a | -all | all) @@ -119,7 +124,7 @@ do shift ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -229,7 +234,7 @@ esac # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage rmdepMode all +unset Script usage error rmdepMode all #------------------------------------------------------------------------------ diff --git a/wmake/wrmo b/wmake/wrmo index b7cab9bf9..b1ce0b1ef 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -41,17 +41,24 @@ Script=${0##*/} . ${0%/*}/scripts/wmakeFunctions usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< USAGE - exit 1 } +error() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + usage + exit 1 +} #------------------------------------------------------------------------------ # Parse arguments and options @@ -64,7 +71,7 @@ while [ "$#" -gt 0 ] do case "$1" in -h | -help) - usage + usage && exit 0 ;; # Non-stop compilation, ignoring errors -a | -all | all) @@ -72,7 +79,7 @@ do shift ;; -*) - usage "unknown option: '$*'" + error "unknown option: '$*'" ;; *) break @@ -110,7 +117,7 @@ fi # Cleanup local variables and functions #------------------------------------------------------------------------------ -unset Script usage +unset Script usage error #------------------------------------------------------------------------------