From 16b509876cb67d2cd962a06c738f9dd31ffce8ad Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 8 Dec 2023 11:51:55 -0500 Subject: [PATCH] Make sensor-dicoms use gnu-getopt if present (on OSX) --- utils/sensor-dicoms | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/sensor-dicoms b/utils/sensor-dicoms index bc42e46c..c47f8442 100755 --- a/utils/sensor-dicoms +++ b/utils/sensor-dicoms @@ -7,8 +7,15 @@ show_usage() { echo "Usage: $0 [--dry-run|-n] --move-to DIRNAME directory [directory2 ...]" } +# On OSX we better use GNU one +if [ -e /usr/local/opt/gnu-getopt/bin/getopt ]; then + getopt=/usr/local/opt/gnu-getopt/bin/getopt +else + getopt=getopt +fi + # Parsing options -TEMP=$(getopt -o 'n' --long move-to:,dry-run -n "$(basename "$0")" -- "$@") +TEMP=$("$getopt" -o 'n' --long move-to:,dry-run -n "$(basename "$0")" -- "$@") # shellcheck disable=SC2181 if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi