<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class="">All right, looks like I have found a good solution thanks to my teammate Jonas. It’s a multi-staged lookup. First, look in $PATH, if it’s not there, try to get it from brew, then from macports.</div><div class="">Additionally, I implemented a lookup for macports so that we do not assume the default path any more.</div><div class="">The execution will also stop, of gnu-getopt could not be found. The user then has to install it.</div><div class="">Finally, I put everything in its own function.</div><div class=""><br class=""></div><div class="">All of this is done in multiple commits, which are based on each other. It should be straight forward to apply the patches.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Part 1:</div><div class=""><div class=""><font face="Menlo" class="">Use three assumed default paths for gnu-getopt lookup</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">brew --prefix gnu-getopt will allways make some git lookups which may take</font></div><div class=""><font face="Menlo" class="">longer, depending on your internet connectivity. We therefore first look</font></div><div class=""><font face="Menlo" class="">in some default location for gnu-getopt. If it is not found there, make</font></div><div class=""><font face="Menlo" class="">the regular lookup.</font></div></div><div class="">========================</div><div class=""><div class=""><font face="Menlo" class="">diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">index 342ecce..4905c7d 100644</font></div><div class=""><font face="Menlo" class="">--- a/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">+++ b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">@@ -43,6 +43,9 @@ qrcode() {</font></div><div class=""><font face="Menlo" class=""> fi</font></div><div class=""><font face="Menlo" class=""> }</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"</font></div><div class=""><font face="Menlo" class="">+GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \</font></div><div class=""><font face="Menlo" class="">+GETOPT="$(brew --prefix gnu-getopt 2>/dev/null)/bin/getopt" || \</font></div><div class=""><font face="Menlo" class="">+GETOPT="$(which port &>/dev/null && echo /opt/local/bin/getopt)"</font></div><div class=""><font face="Menlo" class="">+</font></div><div class=""><font face="Menlo" class=""> SHRED="srm -f -z"</font></div><div class=""><font face="Menlo" class=""> BASE64="openssl base64“</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Part 2:</div><div class=""><div class=""><font face="Menlo" class="">Speed up the brew-based gnu-getop lookup</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">If gnu-getopt is not installed in the brew default path,</font></div><div class=""><font face="Menlo" class="">brew --prefix gnu-getopt will be used, which is annoyingly slow.</font></div><div class=""><font face="Menlo" class="">brew --prefix is way faster and should be prefered.</font></div></div><div class="">========================</div><div class=""><div class=""><font face="Menlo" class="">diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">index 4905c7d..2ee608b 100644</font></div><div class=""><font face="Menlo" class="">--- a/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">+++ b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">@@ -44,7 +44,7 @@ qrcode() {</font></div><div class=""><font face="Menlo" class=""> }</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \</font></div><div class=""><font face="Menlo" class="">-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null)/bin/getopt" || \</font></div><div class=""><font face="Menlo" class="">+GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \</font></div><div class=""><font face="Menlo" class=""> GETOPT="$(which port &>/dev/null && echo /opt/local/bin/getopt)"</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> SHRED="srm -f -z“</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Part 3:</div><div class=""><div class=""><font face="Menlo" class="">Infer gnu-getopt path using MacPorts</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">Unlike using brew, the MacPorts default path is assumed when infering the path to gnu-getopts.</font></div><div class=""><font face="Menlo" class="">This should not be done, since it is possible to install MacPorts and the ports in</font></div><div class=""><font face="Menlo" class="">non-standard paths.</font></div></div><div class="">========================</div><div class=""><div class=""><font face="Menlo" class="">diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">index 2ee608b..220dd78 100644</font></div><div class=""><font face="Menlo" class="">--- a/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">+++ b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">@@ -45,7 +45,7 @@ qrcode() {</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \</font></div><div class=""><font face="Menlo" class=""> GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \</font></div><div class=""><font face="Menlo" class="">-GETOPT="$(which port &>/dev/null && echo /opt/local/bin/getopt)"</font></div><div class=""><font face="Menlo" class="">+GETOPT="$(port content getopt | grep -E '/s?bin/')"</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> SHRED="srm -f -z"</font></div><div class=""><font face="Menlo" class=""> BASE64="openssl base64“</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Part 4:</div><div class=""><div class=""><font face="Menlo" class="">Notify the user if getopt is not installed</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">In the past commits we implemented a new way to find gnu-getopt on macOS.</font></div><div class=""><font face="Menlo" class="">If we can not find it, pass can not be used, thus the user should be</font></div><div class=""><font face="Menlo" class="">notified about this.</font></div></div><div class="">========================</div><div class=""><div class=""><font face="Menlo" class="">diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">index 220dd78..9ff46df 100644</font></div><div class=""><font face="Menlo" class="">--- a/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">+++ b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">@@ -47,5 +47,11 @@ GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local:/usr/local/bin/getopt"</font></div><div class=""><font face="Menlo" class=""> GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \</font></div><div class=""><font face="Menlo" class=""> GETOPT="$(port content getopt | grep -E '/s?bin/')"</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">+echo $GETOPT</font></div><div class=""><font face="Menlo" class="">+if [ ! $GETOPT ]; then</font></div><div class=""><font face="Menlo" class="">+ echo "'getopt' is not installed. Please use 'brew' or 'port' to install it."</font></div><div class=""><font face="Menlo" class="">+ exit 1</font></div><div class=""><font face="Menlo" class="">+fi</font></div><div class=""><font face="Menlo" class="">+</font></div><div class=""><font face="Menlo" class=""> SHRED="srm -f -z"</font></div><div class=""><font face="Menlo" class=""> BASE64="openssl base64“</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Part 5:</div><div class=""><font face="Menlo" class="">Use function for infering gnu-getopt on macOS</font></div><div class="">========================</div><div class=""><div class=""><font face="Menlo" class="">diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">index 9ff46df..9c33c08 100644</font></div><div class=""><font face="Menlo" class="">--- a/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">+++ b/src/platform/darwin.sh</font></div><div class=""><font face="Menlo" class="">@@ -43,15 +43,18 @@ qrcode() {</font></div><div class=""><font face="Menlo" class=""> fi</font></div><div class=""><font face="Menlo" class=""> }</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">-GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \</font></div><div class=""><font face="Menlo" class="">-GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \</font></div><div class=""><font face="Menlo" class="">-GETOPT="$(port content getopt | grep -E '/s?bin/')"</font></div><div class=""><font face="Menlo" class="">+get_getopt() {</font></div><div class=""><font face="Menlo" class="">+ local GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \</font></div><div class=""><font face="Menlo" class="">+ local GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \</font></div><div class=""><font face="Menlo" class="">+ local GETOPT="$(port content getopt | grep -E '/s?bin/')"</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">-echo $GETOPT</font></div><div class=""><font face="Menlo" class="">-if [ ! $GETOPT ]; then</font></div><div class=""><font face="Menlo" class="">- echo "'getopt' is not installed. Please use 'brew' or 'port' to install it."</font></div><div class=""><font face="Menlo" class="">- exit 1</font></div><div class=""><font face="Menlo" class="">-fi</font></div><div class=""><font face="Menlo" class="">+ if [ ! $GETOPT ]; then</font></div><div class=""><font face="Menlo" class="">+ echo "'getopt' is not installed. Please use 'brew' or 'port' to install it."</font></div><div class=""><font face="Menlo" class="">+ exit 1</font></div><div class=""><font face="Menlo" class="">+ fi</font></div><div class=""><font face="Menlo" class="">+ echo $GETOPT</font></div><div class=""><font face="Menlo" class="">+}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">+GETOPT=$(get_getopt)</font></div><div class=""><font face="Menlo" class=""> SHRED="srm -f -z"</font></div><div class=""><font face="Menlo" class=""> BASE64="openssl base64"</font></div></div></body></html>