[PATCH] Speedup pass on macOS and brew
pass-maillinglist at artursterz.de
pass-maillinglist at artursterz.de
Tue Oct 30 10:25:08 CET 2018
As there were no more complaints, I guess my patch is ok? I will tag it [PATCH] and hope, that it will go upstream.
Part 1:
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.
========================
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 342ecce..4905c7d 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“
Part 2:
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.
========================
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 4905c7d..2ee608b 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“
Part 3:
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.
========================
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 2ee608b..220dd78 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“
Part 4:
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.
========================
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 220dd78..9ff46df 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -47,5 +47,11 @@ GETOPT="$(PATH="/usr/local/opt/gnu-getopt/bin:/opt/local:/usr/local/bin/getopt"
GETOPT="$(brew --prefix 2>/dev/null)/opt/gnu-getopt/bin/getopt" || \
GETOPT="$(port content getopt | grep -E '/s?bin/')"
+echo $GETOPT
+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“
Part 5:
Use function for infering gnu-getopt on macOS
========================
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 9ff46df..9c33c08 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,15 +43,18 @@ 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/')"
-echo $GETOPT
-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"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20181030/8d8bfa97/attachment.html>
More information about the Password-Store
mailing list