[PATCH] replace 'which' with POSIX equivalent 'command -v'
Ayush Agarwal
ayush at fastmail.in
Wed Sep 15 17:17:27 UTC 2021
The 'which' command is an external command that must be called each and
every time pass is used. 'which' is also not mentioned in the README as
one of the dependencies that might be needed to run pass.
Instead of 'which', we can use the POSIX compatible and shell built-in
'command -v'. It saves pass from making an external call and is,
arguably, more reliable than using 'which' as mentioned in the following
link.
<https://mywiki.wooledge.org/BashFAQ/081>
---
src/password-store.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/password-store.sh b/src/password-store.sh
index a0dcf2e..f3963e2 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -9,7 +9,7 @@ set -o pipefail
GPG_OPTS=( $PASSWORD_STORE_GPG_OPTS "--quiet" "--yes" "--compress-algo=none" "--no-encrypt-to" )
GPG="gpg"
export GPG_TTY="${GPG_TTY:-$(tty 2>/dev/null)}"
-which gpg2 &>/dev/null && GPG="gpg2"
+command -v gpg2 &>/dev/null && GPG="gpg2"
[[ -n $GPG_AGENT_INFO || $GPG == "gpg2" ]] && GPG_OPTS+=( "--batch" "--use-agent" )
PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
--
2.33.0
More information about the Password-Store
mailing list