From 05be033cd617290d526dcee929c753a5ed5d2118 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 30 Nov 2019 10:35:19 +0000 Subject: [PATCH] pash: abort if PASH_TIMEOUT is an invalid argument to sleep --- pash | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pash b/pash index a5bcd4f..f0296a1 100755 --- a/pash +++ b/pash @@ -60,11 +60,16 @@ pw_copy() { # shellcheck disable=2086 : "${PASH_CLIP:=xclip -selection clipboard}" + printf 'Clearing clipboard in "%s" seconds.\n' \ + "${PASH_TIMEOUT:=10}" + # Wait in the background for the password timeout and # clear the clipboard when the timer runs out. + # + # If the 'sleep' fails, kill the script. This is the + # simplest method of aborting from a subshell. ( - printf 'Clearing clipboard in %d seconds.\n' "${PASH_TIMEOUT:=10}" - sleep "$PASH_TIMEOUT" + sleep "$PASH_TIMEOUT" || kill 0 printf '' | $PASH_CLIP ) &