pash: abort if PASH_TIMEOUT is an invalid argument to sleep
This commit is contained in:
parent
328ca19ad6
commit
05be033cd6
9
pash
9
pash
|
@ -60,11 +60,16 @@ pw_copy() {
|
||||||
# shellcheck disable=2086
|
# shellcheck disable=2086
|
||||||
: "${PASH_CLIP:=xclip -selection clipboard}"
|
: "${PASH_CLIP:=xclip -selection clipboard}"
|
||||||
|
|
||||||
|
printf 'Clearing clipboard in "%s" seconds.\n' \
|
||||||
|
"${PASH_TIMEOUT:=10}"
|
||||||
|
|
||||||
# Wait in the background for the password timeout and
|
# Wait in the background for the password timeout and
|
||||||
# clear the clipboard when the timer runs out.
|
# 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" || kill 0
|
||||||
sleep "$PASH_TIMEOUT"
|
|
||||||
printf '' | $PASH_CLIP
|
printf '' | $PASH_CLIP
|
||||||
) &
|
) &
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue