aboutsummaryrefslogtreecommitdiffstats
path: root/bash-completion
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-01-05 13:40:35 -0500
committerDave Reisner <dreisner@archlinux.org>2013-01-05 13:40:35 -0500
commit1a12102bd68957050899adb69a234258a0dddbb0 (patch)
tree475ef2226442879f4bccec6ddf678e9968a7b67d /bash-completion
parentf2746218d5630ffeb66884fafb85afaabc8c1f0c (diff)
downloadmirror-ponymix-1a12102bd68957050899adb69a234258a0dddbb0.tar.gz
mirror-ponymix-1a12102bd68957050899adb69a234258a0dddbb0.tar.bz2
mirror-ponymix-1a12102bd68957050899adb69a234258a0dddbb0.zip
fix completion for device names with whitespace
Not sure this is the best way, but it's relatively clean, and it works.
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion11
1 files changed, 8 insertions, 3 deletions
diff --git a/bash-completion b/bash-completion
index 56a8b95..2bcce1d 100644
--- a/bash-completion
+++ b/bash-completion
@@ -54,13 +54,15 @@ _ponymix() {
case $prev in
--card|-c)
mapfile -t devices < <(\ponymix list-cards-short 2>/dev/null)
- COMPREPLY=($(compgen -W '${devices[*]}' -- "$cur"))
+ local IFS=$'\n'
+ COMPREPLY=($(compgen -W '$(printf "%s\n" "${devices[@]//\ /\\ }")' -- "$cur"))
;;
--device|-d)
while IFS=$'\t' read _ dev idx _; do
devices+=("$dev" "$idx")
done < <(\ponymix "--${devtype:-sink}" list-short 2>/dev/null)
- COMPREPLY=($(compgen -W '${devices[*]}' -- "$cur"))
+ local IFS=$'\n'
+ COMPREPLY=($(compgen -W '$(printf "%s\n" "${devices[@]//\ /\\ }")' -- "$cur"))
;;
--devtype|-t)
COMPREPLY=($(compgen -W '$types' -- "$cur"))
@@ -96,9 +98,12 @@ _ponymix() {
devices+=("$dev" "$idx")
done < <(\ponymix --source list-short 2>/dev/null)
fi
+ if [[ $devices ]]; then
+ local IFS=$'\n'
+ COMPREPLY=($(compgen -W '$(printf "%s\n" "${devices[@]//\ /\\ }")' -- "$cur"))
+ fi
;;
esac
- [[ $devices ]] && COMPREPLY=($(compgen -W '${devices[*]}' -- "$cur"))
return 0
}