Speedup pass on macOS and brew
pass-maillinglist at artursterz.de
pass-maillinglist at artursterz.de
Thu Oct 25 08:38:25 CEST 2018
So, I have a new version pasted below.
Now, I set $PATH for the script containing the three possible default paths. If we then find, that the macOS default getopt is used, we start the lookup as proposed before.
There is still some not so nice thing. This will only speed up things for users using the default paths of brew and macports. All other users will make the command -v tests. If we could persist the found path at least for the session, it would be great. But I can not find a way to do this except writing a file with the path somewhere, which feels wrong.
Any further suggestions?
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 342ecce..787f5b0 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,6 +43,22 @@ qrcode() {
fi
}
-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"
+export PATH="/usr/local/opt/gnu-getopt/bin:/opt/local/bin:/usr/local/bin:$PATH"
+if [ "$(command -v getopt)" = "/usr/bin/getopt" ]; then
+ GETOPT_PREFIX=""
+ if command -v brew >/dev/null; then
+ GETOPT_PREFIX="$(brew --prefix)/opt/gnu-getopt"
+ if ![ -x "$GETOPT_PREFIX/bin/getopt" ]; then
+ GETOPT_PREFIX=""
+ fi
+ elif [[ $GETOPT_PREFIX ]] && command -v port >/dev/null; then
+ GETOPT_PREFIX="/opt/local"
+ if ![ -x "GETOPT_PREFIX/bin/getopt" ]; then
+ GETOPT_PREFIX=""
+ fi
+ fi
+ GETOPT="${GETOPT_PREFIX:-/usr/local}/bin/getopt"
+fi
+
More information about the Password-Store
mailing list