diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-05-23 13:21:15 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-05-23 13:21:15 +1200 |
commit | 45b5ac8b510400bcccbf893dee2229757533d7a7 (patch) | |
tree | d10021d389a941d6e461f058ed50ec7ddf46efb4 /bash/bash_completion.d/td.bash | |
parent | Avoid awk(1) fork in pph(1df) (diff) | |
download | dotfiles-45b5ac8b510400bcccbf893dee2229757533d7a7.tar.gz dotfiles-45b5ac8b510400bcccbf893dee2229757533d7a7.zip |
Fix up completions for td(1df)
Hung on null completion
Diffstat (limited to 'bash/bash_completion.d/td.bash')
-rw-r--r-- | bash/bash_completion.d/td.bash | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bash/bash_completion.d/td.bash b/bash/bash_completion.d/td.bash index eb29992b..db232dd6 100644 --- a/bash/bash_completion.d/td.bash +++ b/bash/bash_completion.d/td.bash @@ -4,16 +4,23 @@ _td() { dir=${TODO_DIR:-"$HOME"/Todo} local fn while IFS= read -rd '' fn ; do + [[ -n $fn ]] || continue COMPREPLY[${#COMPREPLY[@]}]=$fn done < <( shopt -s extglob nullglob shopt -u dotglob - local -a fns + declare -a fns fns=("$dir"/"${COMP_WORDS[COMP_CWORD]}"*) fns=("${fns[@]#"$dir"/}") - ((${#fns[@]})) || exit 1 - printf '%s\0' "${fns[@]##"$dir"/}" + + # Print quoted entries, null-delimited, if there was at least one; + # otherwise, just print a null character to stop this hanging in Bash + # 4.4 + if ((${#fns[@]})) ; then + printf '%q\0' "${fns[@]}" + else + printf '\0' + fi ) - return } complete -F _td td |