[PATCH 2/5] Speed up the brew-based gnu-getop lookup
If gnu-getopt is not installed in the brew default path, brew --prefix gnu-getopt will be used, which is annoyingly slow. brew --prefix is way faster and should be prefered. --- src/platform/darwin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh index e00b928..bc232c3 100644 --- a/src/platform/darwin.sh +++ b/src/platform/darwin.sh @@ -44,7 +44,7 @@ qrcode() { } GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \ -GETOPT="$(brew --prefix gnu-getopt 2>/dev/null)/bin/getopt" || \ +GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \ GETOPT="$(which port &>/dev/null && echo /opt/local/bin/getopt)" SHRED="srm -f -z" -- 2.17.1 (Apple Git-112) ___ Password-Store mailing list Password-Store@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/password-store
[PATCH 4/5] Notify the user if getopt is not installed
In the past commits we implemented a new way to find gnu-getopt on macOS. If we can not find it, pass can not be used, thus the user should be notified about this. --- src/platform/darwin.sh | 5 + 1 file changed, 5 insertions(+) diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh index 1d9ac8f..a9d32ce 100644 --- a/src/platform/darwin.sh +++ b/src/platform/darwin.sh @@ -47,5 +47,10 @@ GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" com GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \ 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 + SHRED="srm -f -z" BASE64="openssl base64" -- 2.17.1 (Apple Git-112) ___ Password-Store mailing list Password-Store@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/password-store
[PATCH 1/5] Use three assumed default paths for gnu-getopt lookup
brew --prefix gnu-getopt will allways make some git lookups which may take longer, depending on your internet connectivity. We therefore first look in some default location for gnu-getopt. If it is not found there, make the regular lookup. --- src/platform/darwin.sh | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh index 342ecce..e00b928 100644 --- a/src/platform/darwin.sh +++ b/src/platform/darwin.sh @@ -43,6 +43,9 @@ qrcode() { fi } -GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt" +GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin" command -v getopt)" || \ +GETOPT="$(brew --prefix gnu-getopt 2>/dev/null)/bin/getopt" || \ +GETOPT="$(which port &>/dev/null && echo /opt/local/bin/getopt)" + SHRED="srm -f -z" BASE64="openssl base64" -- 2.17.1 (Apple Git-112) ___ Password-Store mailing list Password-Store@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/password-store
[PATCH 3/5] Infer gnu-getopt path using MacPorts
Unlike using brew, the MacPorts default path is assumed when infering the path to gnu-getopts. This should not be done, since it is possible to install MacPorts and the ports in non-standard paths. --- src/platform/darwin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh index bc232c3..1d9ac8f 100644 --- a/src/platform/darwin.sh +++ b/src/platform/darwin.sh @@ -45,7 +45,7 @@ qrcode() { 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="$(which port &>/dev/null && echo /opt/local/bin/getopt)" +GETOPT="$(port content getopt | grep -E '/s?bin/')" SHRED="srm -f -z" BASE64="openssl base64" -- 2.17.1 (Apple Git-112) ___ Password-Store mailing list Password-Store@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/password-store
[PATCH 5/5] Move gnu-getopt path infering into own function
--- 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) ___ Password-Store mailing list Password-Store@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/password-store