From f89597d110935a35897c76a169c1119f4f849fda Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 4 Jun 2015 01:16:04 +1200 Subject: Handle empty pass(1) completes better --- bash/bashrc.d/pass.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bash/bashrc.d') diff --git a/bash/bashrc.d/pass.bash b/bash/bashrc.d/pass.bash index d60a6022..61550b9e 100644 --- a/bash/bashrc.d/pass.bash +++ b/bash/bashrc.d/pass.bash @@ -19,11 +19,9 @@ _pass() local word=${COMP_WORDS[COMP_CWORD]} local entry while read -d '' -r entry ; do - if [[ $entry && $entry == "$word"* ]] ; then + if [[ $entry == "$word"* ]] ; then COMPREPLY=("${COMPREPLY[@]}" "$entry") fi - - # This part provides the input to the while loop done < <( # Set shell options to expand globs the way we expect @@ -40,7 +38,9 @@ _pass() entries=("${entries[@]%.gpg}") # Print all the entries, null-delimited - printf '%s\0' "${entries[@]}" + if ((${#entries[@]})) ; then + printf '%s\0' "${entries[@]}" + fi ) } complete -F _pass pass -- cgit v1.2.3