Speedup pass on macOS and brew

pass-maillinglist at artursterz.de pass-maillinglist at artursterz.de
Tue Oct 23 18:05:44 CEST 2018


> The only thing that annoys me with the code above is that we always execute brew, though technically the overhead is the same or less than guarding it with a command -v brew statement (less for people who have the executable).

Okay, I see your point. Maybe we can ditch this all together? As far as I can see from the documentation (https://docs.brew.sh/Installation <https://docs.brew.sh/Installation>), there are about no chances that the brew prefix is not /usr/local.
It requires similar steps as for macports (https://www.macports.org/install.php <https://www.macports.org/install.php>) to install brew somewhere else then in its default path. But for macports, pass assumes the default path anyway, so we could do this for brew, could we?
Additionally, this is a somewhat failsafe version. If neither of the three options is available the user will have trouble using pass anyways, so the test -x check should be enough.

A patch based on Allans suggestions is appended.


diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 342ecce..a984bec 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,6 +43,10 @@ qrcode() {
        fi
 }

-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null && echo /opt/local; } || echo /usr/local)/bin/getopt"
+for prefix in /usr/local/opt/gnu-getopt /opt/local /usr/local; do
+    GETOPT="${prefix}/bin/getopt"
+    test -x "$GETOPT" && break
+done
+
 SHRED="srm -f -z"
 BASE64="openssl base64"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20181023/4f1b0f68/attachment.html>


More information about the Password-Store mailing list