aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorWieland Hoffmann <themineo@gmail.com>2015-01-19 14:07:07 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2015-01-19 14:15:51 +0100
commit0524ef9aad5e908c4062c2696a3b7a807bd494c7 (patch)
tree00e79bc71bc1e7b4e7de6bfbf17de0cb7b32f802 /src
parentCorrect path for top level grep (diff)
downloadpassword-store-0524ef9aad5e908c4062c2696a3b7a807bd494c7.tar.xz
password-store-0524ef9aad5e908c4062c2696a3b7a807bd494c7.zip
clip: Show an error message if xclip returns a non-zero exit code
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.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/password-store.sh5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index 160250f..efe0f3d 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -131,11 +131,10 @@ 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"
+ local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | base64)"
+ echo -n "$1" | xclip -selection "$X_SELECTION" || die "Error: Could not copy data to the clipboard"
(
( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
local now="$(xclip -o -selection "$X_SELECTION" | base64)"