[pass] [PATCH] clip: Show an error message if xclip returns a non-zero exit code
Wieland Hoffmann
themineo at gmail.com
Fri Jan 16 20:38:52 CET 2015
xclip will return a non-zero exit code if $DISPLAY is not set, which
might happen, for example, if you're running pass in a tmux session
remotely or something like that. xclip itself will also show an error
message ("Can't open display") which provides enough context to figure
out what the problem is.
There might be other reasons for xclip to return a non-zero exit code,
but the man page doesn't list them.
---
I'm not entirely sure if this is ready for inclusion yet as *both* calls to
xclip before the error check show xclips error message - redirecting the output
of one of them might be a good idea because only the exit code of one of the
calls is checked anyways. Feedback is welcome :-)
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 d4e9515..3f7417d 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -131,11 +131,11 @@ clip() {
# This base64 business is because bash cannot store binary data in a shell
# variable. Specifically, it cannot store nulls nor (non-trivally) store
# trailing new lines.
-
local sleep_argv0="password store sleep on display $DISPLAY"
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
local before="$(xclip -o -selection "$X_SELECTION" | base64)"
echo -n "$1" | xclip -selection "$X_SELECTION"
+ [ $? -ne 0 ] && die "Error: Could not copy data to the clipboard."
(
( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
local now="$(xclip -o -selection "$X_SELECTION" | base64)"
--
2.2.2
More information about the Password-Store
mailing list