From 0198bc13a176973e6b3efa989b8ad318251b8308 Mon Sep 17 00:00:00 2001 From: Philip Sequeira Date: Sat, 14 Dec 2019 13:38:45 -0500 Subject: 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. --- etc/_mpv.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/etc/_mpv.zsh b/etc/_mpv.zsh index 131a61b51e..7837d60411 100644 --- a/etc/_mpv.zsh +++ b/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 -- cgit v1.2.3