<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">On 22 Oct 2018, at 23:50, <a href="mailto:pass-maillinglist@artursterz.de" style="color:#3983C4">pass-maillinglist@artursterz.de</a> wrote:</p>

</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">currently (and as I can tell also in the past, see [1],[2],[3],[4],[5]), brew —prefix <FORMULA> is really slow (see the example output below), which makes it somewhat annoying using pass on macOS. I hunted this down and found that the problem is the following: brew runs git rev-parse --short=4 --verify -q HEAD every time to find the currently installed version of the formula (which seems somewhat unreasonable). Depending on your git and network connectivity, this may take longer. Using brew —prefix without a formula is reasonably fast. As far as I can tell, there is currently no way to change the prefix path in brew, thus using $(brew —prefix)/opt/gnu-getopt should be a save way for determining the path to gnu-getopt.</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">Great find! I’ve been somewhat annoyed myself by the ~1s delay when using <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">pass</code>, but always assumed it was just GPG being slow.</p>

</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">I patched this and attached the patch to this mail. Since my implementation is somewhat longer, I think it should not be implemented in one line anymore, but split it up as I did (see the patch). If you come up with something better let me know (or, of course, patch it yourself). Additionally, since I am not using Macports, I can not test if this also works with ports. Before considering pushing my patch upstream, someone needs to test this! For brew, it works fine.</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">The <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">elif</code> and <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">else</code> branches look wrong, as we are not in a command context, so shouldn’t prefix with <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">echo</code>, plus including the <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">which</code> line is redundant when the <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">elif</code> already test for the presence of <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">port</code>.</p>

<p dir="auto">I also find it cleaner to test the exit status of <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">command</code> instead of testing against non-zero output.</p>

<p dir="auto">Here’s my revised proposal for the relevant code to setup <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">GETOPT</code>:</p>

<pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7">if command -v brew >/dev/null; then
    GETOPT_PREFIX="$(brew --prefix)/opt/gnu-getopt"
elif command -v port >/dev/null; then
    GETOPT_PREFIX="/opt/local"
fi
GETOPT="${GETOPT_PREFIX:-/usr/local}/bin/getopt"
</code></pre>

<p dir="auto">If we find neither <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">brew</code> nor <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">port</code> then we use <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">GETOPT_PREFIX</code> before falling back to <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">/usr/local</code>.</p>

<p dir="auto">Don’t think we actually need this, but it makes the code look nicer :)</p>
</div>
</div>
</body>
</html>