mirror of https://github.com/mpv-player/mpv
zsh completion: use actual POSIX-compatible regex for whitespace
\s and \S aren't actually part of the spec, but it seems glibc supports them anyway so I didn't notice when originally testing. This fixes the script on Apple's libc and probably others that adhere more closely to the spec. The most direct replacement for \s would have been [[:space:]], but we only expect to see spaces and tabs, so might as well just do that. Also could have used [[:blank:]], which is basically a locale-aware version of [ \t], but mpv isn't going to output anything but ASCII spaces and tabs, so let's avoid unnecessary complexity and stick with the ASCII literals.
This commit is contained in:
parent
a921c0628e
commit
0198bc13a1
10
etc/_mpv.zsh
10
etc/_mpv.zsh
|
@ -44,7 +44,7 @@ function generate_arguments {
|
|||
local list_options_line
|
||||
for list_options_line in "${(@f)$($words[1] --list-options)}"; do
|
||||
|
||||
[[ $list_options_line =~ '^\s+--(\S+)\s*(.*)' ]] || continue
|
||||
[[ $list_options_line =~ $'^[ \t]+--([^ \t]+)[ \t]*(.*)' ]] || continue
|
||||
|
||||
local name=$match[1] desc=$match[2]
|
||||
|
||||
|
@ -72,7 +72,7 @@ function generate_arguments {
|
|||
|
||||
_mpv_completion_arguments+="$name"
|
||||
|
||||
elif [[ $desc =~ '^alias for --(\S+)' ]]; then
|
||||
elif [[ $desc =~ $'^alias for --([^ \t]+)' ]]; then
|
||||
|
||||
# Save this for later; we might not have parsed the target option yet
|
||||
option_aliases+="$name $match[1]"
|
||||
|
@ -147,7 +147,7 @@ function generate_protocols {
|
|||
_mpv_completion_protocols=()
|
||||
local list_protos_line
|
||||
for list_protos_line in "${(@f)$($words[1] --list-protocols)}"; do
|
||||
if [[ $list_protos_line =~ '^\s+(.*)' ]]; then
|
||||
if [[ $list_protos_line =~ $'^[ \t]+(.*)' ]]; then
|
||||
_mpv_completion_protocols+="$match[1]"
|
||||
fi
|
||||
done
|
||||
|
@ -192,7 +192,7 @@ case $state in
|
|||
local pattern name_group=1 desc_group=2
|
||||
case $option_name in
|
||||
audio-device|vulkan-device)
|
||||
pattern='^\s+'\''([^'\'']*)'\''\s+\((.*)\)'
|
||||
pattern=$'^[ \t]+'\''([^'\'']*)'\'$'[ \t]+''\((.*)\)'
|
||||
;;
|
||||
profile)
|
||||
# The generic pattern would actually work in most cases for --profile,
|
||||
|
@ -201,7 +201,7 @@ case $state in
|
|||
pattern=$'^\t([^\t]*)\t(.*)'
|
||||
;;
|
||||
*)
|
||||
pattern='^\s+(--'${option_name}'=)?(\S+)\s*[-:]?\s*(.*)'
|
||||
pattern=$'^[ \t]+(--'${option_name}$'=)?([^ \t]+)[ \t]*[-:]?[ \t]*(.*)'
|
||||
name_group=2 desc_group=3
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue