diff options
Diffstat (limited to 'bash/bash_completion.d/ud.bash')
-rw-r--r-- | bash/bash_completion.d/ud.bash | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/bash/bash_completion.d/ud.bash b/bash/bash_completion.d/ud.bash index aa59a4fc..c7dee582 100644 --- a/bash/bash_completion.d/ud.bash +++ b/bash/bash_completion.d/ud.bash @@ -2,40 +2,32 @@ _ud() { # Only makes sense for the second argument - ((COMP_CWORD == 2)) || return 1 + ((COMP_CWORD == 2)) || return # Iterate through directories, null-separated, add them to completions local dirname while IFS= read -rd '' dirname ; do + [[ -n "$dirname" ]] || continue COMPREPLY[${#COMPREPLY[@]}]=$dirname done < <( # Set options to glob correctly shopt -s dotglob nullglob - # Make globbing case-insensitive if appropriate; is there a cleaner way - # to find this value? - while read -r _ option value ; do - case $option in - (completion-ignore-case) - case $value in - (on) - shopt -s nocaseglob - break - ;; - esac + # Make globbing case-insensitive if appropriate + while read -r _ setting ; do + case $setting in + ('completion-ignore-case on') + shopt -s nocaseglob + break ;; esac done < <(bind -v) # Collect directory names, strip trailing slashes - local -a dirnames dirnames=("${COMP_WORDS[COMP_CWORD]}"*/) dirnames=("${dirnames[@]%/}") - # Bail if no results to prevent empty output - ((${#dirnames[@]})) || exit 1 - # Print results null-delimited printf '%s\0' "${dirnames[@]}" ) |