[PATCH 5/5] Move gnu-getopt path infering into own function

Artur Sterz pass-maillinglist at artursterz.de
Tue Oct 30 18:06:28 CET 2018


---
 src/platform/darwin.sh | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index a9d32ce..75db6a0 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,14 +43,19 @@ qrcode() {
 	fi
 }
 
-GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \
-GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \
-GETOPT="$(port content getopt | grep -E '/s?bin/')"
+get_getopt() {
+	local GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \
+	local GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \
+	local GETOPT="$(port content getopt | grep -E '/s?bin/')"
 
-if [ ! $GETOPT ]; then
-	echo "'getopt' is not installed. Please use 'brew' or 'port' to install it."
-	exit 1
-fi
+	if [ ! $GETOPT ]; then
+		echo "'getopt' is not installed. Please use 'brew' or 'port' to install it."
+		exit 1
+	fi
+
+	echo $GETOPT
+}
 
+GETOPT=$(get_getopt)
 SHRED="srm -f -z"
 BASE64="openssl base64"
-- 
2.17.1 (Apple Git-112)



More information about the Password-Store mailing list