From 1a12102bd68957050899adb69a234258a0dddbb0 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 5 Jan 2013 13:40:35 -0500 Subject: fix completion for device names with whitespace Not sure this is the best way, but it's relatively clean, and it works. --- bash-completion | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bash-completion') 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 } -- cgit v1.2.3