summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sequeira <phsequei@gmail.com>2019-12-14 13:38:45 -0500
committerwm4 <1387750+wm4@users.noreply.github.com>2019-12-15 14:17:00 +0100
commit0198bc13a176973e6b3efa989b8ad318251b8308 (patch)
tree6836462f1b4dc0a882b9198aa42941618e2c1c54
parenta921c0628ecaa38a40b06280ef89be3e1f64d457 (diff)
downloadmpv-0198bc13a176973e6b3efa989b8ad318251b8308.tar.bz2
mpv-0198bc13a176973e6b3efa989b8ad318251b8308.tar.xz
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.
-rw-r--r--etc/_mpv.zsh10
1 files 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