STYLE: allow '=' option separators in some bin/tools scripts

This commit is contained in:
Mark Olesen 2019-06-26 11:27:53 +02:00 committed by Andrew Heather
parent ff81ec8cf3
commit f7a707e00e
5 changed files with 39 additions and 19 deletions

View File

@ -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.

View File

@ -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()

View File

@ -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" ]

View File

@ -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 <<USAGE
Usage: ${0##*/} [OPTION] commit-ish
options:
-output DIR Specify alternative output directory
-output=dir Write to alternative output directory
-no-modules Exclude submodules
-no-patch Ignore _patch number for the output tar-file
-compress=TYPE Compress with specified type
@ -78,6 +78,7 @@ die()
exit 1
}
#-------------------------------------------------------------------------------
outputDir="."
unset skipModules skipPatchNum
@ -94,6 +95,9 @@ do
outputDir="$2"
shift
;;
-output=*)
outputDir="${1#*=}"
;;
-no-modules)
skipModules=true
;;
@ -291,7 +295,7 @@ case "$compress" in
(tgz)
echo "Using gzip compression with tgz ending" 1>&2
echo 'gzip -c9 "$outputDir/$tarName.tar" > "$outputDir/$tarName.tgz"'
echo 'gzip -c -9 "$outputDir/$tarName.tar" > "$outputDir/$tarName.tgz"'
;;
(bz | bzip | bzip2)

View File

@ -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+$' -- $@
#------------------------------------------------------------------------------