aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash')
-rw-r--r--bash/bash_completion.d/td.bash15
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