<!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 23 Oct 2018, at 20:01, <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"><blockquote style="border-left:2px solid #777; color:#999; margin:0 0 5px; padding-left:5px; border-left-color:#999"><p dir="auto">Also, if it is desirable with additional fault tolerance, I would argue it belongs in a different commit, as it’s unrelated to the optimization that is being proposed.</p>
</blockquote><p dir="auto">I guess having a version that is reasonably fast and fault tolerant at the same time would be great.</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">This is just my personal opinion, but one commit should do only one thing.</p>

<p dir="auto">Say the extra checks break it for MacPort users, so someone may decide to revert the commit because it was faulty, but then we also lose the homebrew optimization, even though that part worked fine.</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 pasted a fourth version below, which tries to handle the case, that brew is available, but gnu-getopt was not installed using brew. I also implemented the test for macports, but again since I am not using macports, I can not test this.<br>
<br>
What do you think?</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">Since we are moving away from testing “does the user have <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">brew</code>? OK, assume they installed <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">getopt</code>” to testing whether <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">getopt</code> actually exists in a set of likely directories, I suggest the code be rewritten to use this approach:</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">for prefix in "$(brew --prefix 2>/dev/null)/opt/gnu-getopt" /opt/local /usr/local; do
    GETOPT="${prefix}/bin/getopt"
    test -x "$GETOPT" && break
done
</code></pre>

<p dir="auto">We could add a final check (after the loop) to see if <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">GETOPT</code> is executable, but an error should be thrown regardless, it will just be at a later time.</p>

<p dir="auto">The only thing that annoys me with the code above is that we always execute <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">brew</code>, though technically the overhead is the same or less than guarding it with a <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">command -v brew</code> statement (less for people who have the executable).</p>
</div>
</div>
</body>
</html>