Merge branch 'master' into 'master'

shell-completion: fix bash completion if a profile or a port contains spaces

See merge request pulseaudio/pulseaudio!861
This commit is contained in:
Robin Ebert 2026-01-06 16:38:31 +01:00
commit 20d87b5393

View file

@ -48,7 +48,7 @@ __ports () {
flag { flag {
if (/^\t\t[A-Za-z]/) if (/^\t\t[A-Za-z]/)
ports = ports substr($0, 3, index($0, ":")-3) " " ports = ports substr($0, 3, index($0, ":")-3) "\n"
} }
END { END {
@ -68,7 +68,7 @@ __profiles () {
flag { flag {
if (/^\t\t[A-Za-z]/) if (/^\t\t[A-Za-z]/)
profiles = profiles substr($0, 3, index($0, ": ")-3) " " profiles = profiles substr($0, 3, index($0, ": ")-3) "\n"
} }
END { END {
@ -108,6 +108,20 @@ in_array() {
done done
} }
_profiles_helper() {
local IFS=$'\n'
comps="$(__profiles)"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$1"))
compopt -o fullquote
}
_ports_helper() {
local IFS=$'\n'
comps="$(__ports)"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$1"))
compopt -o fullquote
}
_pactl() { _pactl() {
local cur prev words cword preprev word command local cur prev words cword preprev word command
local comps local comps
@ -153,13 +167,11 @@ _pactl() {
;; ;;
set-card-profile) set-card-profile)
comps=$(__profiles) _profiles_helper "$cur"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
;; ;;
set-*-port) set-*-port)
comps=$(__ports) _ports_helper "$cur"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
;; ;;
set-*-mute) COMPREPLY=($(compgen -W 'true false toggle' -- "$cur")) ;; set-*-mute) COMPREPLY=($(compgen -W 'true false toggle' -- "$cur")) ;;
@ -168,8 +180,7 @@ _pactl() {
;; #TODO ;; #TODO
set-port-*) set-port-*)
comps=$(__ports) _ports_helper "$cur"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
;; ;;
--server) --server)
compopt +o nospace compopt +o nospace
@ -304,13 +315,11 @@ _pacmd() {
;; ;;
set-card-profile) set-card-profile)
comps=$(__profiles) _profiles_helper "$cur"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
;; ;;
set-*port*) set-*port*)
comps=$(__ports) _ports_helper "$cur"
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
;; ;;
set-*-mute) COMPREPLY=($(compgen -W 'true false' -- "$cur"));; set-*-mute) COMPREPLY=($(compgen -W 'true false' -- "$cur"));;