From c4554e6784cac99f1f8499fc5c7898ee8cd1e31a Mon Sep 17 00:00:00 2001
From: Julien Laffaye <jlaffaye@FreeBSD.org>
Date: Tue, 1 Aug 2017 00:07:18 +0200
Subject: [PATCH] Directly look for gnu-getopt candidates

Running external commands, especially brew, to get the gnu-getopt
location can be very time consuming.
I can see as nearly as 4x speed improvement with this simple change.
---
 src/platform/darwin.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 86eb325..c189716 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,5 +43,12 @@ qrcode() {
 	fi
 }
 
-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"
+GETOPTS_CANDIDATES="/usr/local/opt/gnu-getopt/bin/getopt /opt/local/bin/getopt /usr/local/bin/getopt"
+
+for c in $GETOPTS_CANDIDATES; do
+    if [[ -x "$c" ]]; then
+        GETOPT=$c
+    fi
+done
+
 SHRED="srm -f -z"
-- 
2.11.0 (Apple Git-81)

