On Thu, 25 Jun 2020, Kjetil Torgrim Homme wrote:
On 6/24/20 10:23 PM, [email protected] wrote:
That's a fair point - my main reason for doing it this way was that I
imagined exiting with the same code as the git command would be more
useful, so users can treat `pass git [...]` as a transparent wrapper,
particularly for commands that specify specific exit codes. Happy to
change it if people would prefer the consistent use of die() / exit code
of 1.
I would prefer to keep the information from git exit codes intact as
well, but this should be documented in the manual page. I see there is
no EXIT CODES section today, so there isn't really any documented
behaviour to break.
Cool - documentation added, also removed two odd-one-out cases of $?.
Thanks,
Rob
From a330c6045fcd89765b8cd1587e3125be43c7355c Mon Sep 17 00:00:00 2001
From: Rob Pilling <[email protected]>
Date: Sun, 28 Jun 2020 17:37:19 +0100
Subject: [PATCH 3/3] Document exit codes
---
man/pass.1 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/man/pass.1 b/man/pass.1
index a555dcb..30f7d39 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -465,6 +465,9 @@ The \fBinit\fP command will keep signatures of \fB.gpg-id\fP files up to date.
.TP
.I EDITOR
The location of the text editor used by \fBedit\fP.
+.SH EXIT CODES
+\fBpass\fP exits 0 on success, and 1 otherwise, except for the \fBgit\fP command, which returns
+the exit code of the git process it executes.
.SH SEE ALSO
.BR gpg2 (1),
.BR tr (1),
--
2.20.1 (Apple Git-117)
From af521f35887a80907bf40b3a2f0159db9584d104 Mon Sep 17 00:00:00 2001
From: Rob Pilling <[email protected]>
Date: Sun, 28 Jun 2020 17:37:08 +0100
Subject: [PATCH 2/3] Unify exit code for `base64` or `head` failure
---
src/password-store.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/password-store.sh b/src/password-store.sh
index aa8c745..45200ea 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -382,11 +382,11 @@ cmd_show() {
check_sneaky_paths "$path"
if [[ -f $passfile ]]; then
if [[ $clip -eq 0 && $qrcode -eq 0 ]]; then
- pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit $?
+ pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit 1
echo "$pass" | $BASE64 -d
else
[[ $selected_line =~ ^[0-9]+$ ]] || die "Clip location '$selected_line' is not a number."
- pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${selected_line} | head -n 1)" || exit $?
+ pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${selected_line} | head -n 1)" || exit 1
[[ -n $pass ]] || die "There is no password to put on the clipboard at line ${selected_line}."
if [[ $clip -eq 1 ]]; then
clip "$pass" "$path"
--
2.20.1 (Apple Git-117)
From dc0552fc7d38f3f694fb7731fd85a3ad04b91445 Mon Sep 17 00:00:00 2001
From: Rob Pilling <[email protected]>
Date: Wed, 17 Jun 2020 20:02:24 +0100
Subject: [PATCH 1/3] Exit with git's error code for `pass git [...]`
---
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 77f3eda..aa8c745 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -661,7 +661,7 @@ cmd_git() {
elif [[ -n $INNER_GIT_DIR ]]; then
tmpdir nowarn #Defines $SECURE_TMPDIR. We don't warn, because at most, this only copies encrypted files.
export TMPDIR="$SECURE_TMPDIR"
- git -C "$INNER_GIT_DIR" "$@"
+ git -C "$INNER_GIT_DIR" "$@" || exit $?
else
die "Error: the password store is not a git repository. Try \"$PROGRAM git init\"."
fi
--
2.20.1 (Apple Git-117)