> Am 23.10.2018 um 13:35 schrieb Allan Odgaard <lists+p...@simplit.com>:
>
> On 23 Oct 2018, at 18:11, pass-maillingl...@artursterz.de
> <mailto:pass-maillingl...@artursterz.de> wrote:
>
> But you are right in one part, Amir. Just because brew or macports are
> installed doesn't mean that gnu-getopts was installed with either tool.
> Therefore, we should check if either is installed AND if gnu-getopt is in the
> path we assume. If nothing is true, then (and only then) use any reasonable
> fall back.
>
> But I have to think about it and make a diff as soon as I am ready.
>
> At least for homebrew, the pass formula depends on gnu-getopt, therefor only
> a user who has brew installed but who did a custom install of pass, could run
> into an issue of missing gnu-getopt.
>
> I think such scenario is unlikely, especially as brew allows installing pass
> directly from git (using HEAD).
>
> 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.
>
I guess having a version that is reasonably fast and fault tolerant at the same
time would be great. 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.
What do you think?
diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 342ecce..e402120 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -43,6 +43,19 @@ qrcode() {
fi
}
-GETOPT="$(brew --prefix gnu-getopt 2>/dev/null || { which port &>/dev/null &&
echo /opt/local; } || echo /usr/local)/bin/getopt"
+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"
+
SHRED="srm -f -z"
BASE64="openssl base64"
_______________________________________________
Password-Store mailing list
Password-Store@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/password-store