From f7a707e00ed9631896e7b3e557b8b239babb34d1 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 26 Jun 2019 11:27:53 +0200 Subject: [PATCH] STYLE: allow '=' option separators in some bin/tools scripts --- bin/tools/README | 4 ++-- bin/tools/foamConfigurePaths | 3 +-- bin/tools/foamCreateManpage | 37 +++++++++++++++++++++++--------- bin/tools/foamPackRelease | 10 ++++++--- bin/tools/git-find-trailingspace | 4 ++-- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/bin/tools/README b/bin/tools/README index 2b98a9702f..7464f8e763 100644 --- a/bin/tools/README +++ b/bin/tools/README @@ -1,2 +1,2 @@ -Misc. tools, scripts, templates that are useful (eg, for building applications) -but don't need to be in the PATH. +Miscellaneous tools, scripts, templates that are useful +(eg, for building applications) but don't need to be in the PATH. diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths index a657966995..12c1297e04 100755 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -209,8 +209,7 @@ replaceCsh() done } -# Get the option's value (argument). -# Die if the argument doesn't exist or is empty +# Get the option's value (argument), or die on missing or empty argument # $1 option # $2 value getOptionValue() diff --git a/bin/tools/foamCreateManpage b/bin/tools/foamCreateManpage index 9888413e36..cf628cae7c 100755 --- a/bin/tools/foamCreateManpage +++ b/bin/tools/foamCreateManpage @@ -26,11 +26,11 @@ usage() { Usage: ${0##*/} [OPTION] [appName .. [appNameN]] options: - -dir DIR Directory to process - -output DIR Write to alternative output directory + -dir=DIR Input directory to process + -output=DIR Write to alternative output directory -pdf Process as nroff man content and pass to ps2pdf -gz | -gzip Compress manpage output - -version VER Specify an alternative version + -version=VER Specify an alternative version -h | -help Print the usage Query OpenFOAM applications with -help-man for their manpage content @@ -58,6 +58,15 @@ die() exit 1 } +# Get the option's value (argument), or die on missing or empty argument +# $1 option +# $2 value +getOptionValue() +{ + [ -n "$2" ] || die "'$1' option requires an argument" + echo "$2" +} + #------------------------------------------------------------------------------- searchDirs="$FOAM_APPBIN" unset sedFilter outputDir outputType @@ -68,9 +77,12 @@ do -h | -help*) usage ;; + -dir=*) + searchDirs="${1#*=}" + [ -d "$searchDirs" ] || die "directory not found '$searchDirs'" + ;; -dir) - [ "$#" -ge 2 ] || die "'$1' option requires an argument" - searchDirs="$2" + searchDirs=$(getOptionValue "$@") [ -d "$searchDirs" ] || die "directory not found '$searchDirs'" shift ;; @@ -80,15 +92,20 @@ do -pdf) outputType="pdf" ;; + -version=*) + version="${1#*=}" + sedFilter='s/OpenFOAM-[^\"]*/OpenFOAM-'"$version/" + ;; -version) - [ "$#" -ge 2 ] || die "'$1' option requires an argument" - version="$2" + version=$(getOptionValue "$@") sedFilter='s/OpenFOAM-[^\"]*/OpenFOAM-'"$version/" shift ;; + -output=*) + outputDir="${1#*=}" + ;; -output) - [ "$#" -ge 2 ] || die "'$1' option requires an argument" - outputDir="$2" + outputDir=$(getOptionValue "$@") shift ;; -*) @@ -101,7 +118,7 @@ do shift done -: ${outputDir:=$defaultOutputDir} +: "${outputDir:=$defaultOutputDir}" # Verify that output is writeable if [ -e "$outputDir" ] diff --git a/bin/tools/foamPackRelease b/bin/tools/foamPackRelease index 6985182665..761137049e 100755 --- a/bin/tools/foamPackRelease +++ b/bin/tools/foamPackRelease @@ -28,7 +28,7 @@ # Description # Simple script generator for packing OpenFOAM sources and submodules # -# $ foamPackRelease -output some/path origin/master > create-tar +# $ foamPackRelease -output=some/path origin/master > create-tar # $ bash ./create-tar # # Or directly: @@ -46,7 +46,7 @@ cat <&2 - echo 'gzip -c9 "$outputDir/$tarName.tar" > "$outputDir/$tarName.tgz"' + echo 'gzip -c -9 "$outputDir/$tarName.tar" > "$outputDir/$tarName.tgz"' ;; (bz | bzip | bzip2) diff --git a/bin/tools/git-find-trailingspace b/bin/tools/git-find-trailingspace index e6e74e4339..9531918e30 100755 --- a/bin/tools/git-find-trailingspace +++ b/bin/tools/git-find-trailingspace @@ -4,10 +4,10 @@ # git-find-trailingspace # # Description -# Use git grep to search for files with trailing whitespace +# Use git grep to find files with trailing whitespace # #------------------------------------------------------------------------------ -git grep -c -P '\s+$' -- $@ +git grep --count -P '\s+$' -- $@ #------------------------------------------------------------------------------