summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorPhilip Sequeira <phsequei@gmail.com>2016-09-10 14:53:55 -0400
committerwm4 <wm4@nowhere>2016-09-10 21:46:01 +0200
commitdefcb9047e18f6c9fe1129fb85915344a6a57126 (patch)
treeda7d04295e97609aef4b750ba49ab88618191ba1 /TOOLS
parentfc1c004cd8b869f268e3d8eb3bf605bc39902e99 (diff)
downloadmpv-defcb9047e18f6c9fe1129fb85915344a6a57126.tar.bz2
mpv-defcb9047e18f6c9fe1129fb85915344a6a57126.tar.xz
TOOLS/zsh.pl: die if we can't parse main options
This will catch cases where mpv runs without error, but the --list-options output isn't what we expect. Otherwise, we'll make a broken completion file that will result in cryptic errors when pressing tab, like: _mpv:18: command not found: *:files:->mfiles That's been the case for most of the zsh completion issues we've had reported, that I can remember. Also make uninitialized variable access fatal so that failures to parse other options will also make the script die eventually, albeit with a less nice message.
Diffstat (limited to 'TOOLS')
-rwxr-xr-xTOOLS/zsh.pl3
1 files changed, 3 insertions, 0 deletions
diff --git a/TOOLS/zsh.pl b/TOOLS/zsh.pl
index 809a8a4d8a..7d354b4c47 100755
--- a/TOOLS/zsh.pl
+++ b/TOOLS/zsh.pl
@@ -4,11 +4,14 @@
use strict;
use warnings;
+use warnings FATAL => 'uninitialized';
my $mpv = $ARGV[0] || 'mpv';
my @opts = parse_main_opts('--list-options', '^ (\-\-[^\s\*]*)\*?\s*(.*)');
+die "Couldn't find any options" unless (@opts);
+
my @ao = parse_opts('--ao=help', '^ ([^\s\:]*)\s*: (.*)');
my @vo = parse_opts('--vo=help', '^ ([^\s\:]*)\s*: (.*)');