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.
This commit is contained in:
Philip Sequeira 2016-09-10 14:53:55 -04:00 committed by wm4
parent fc1c004cd8
commit defcb9047e
1 changed files with 3 additions and 0 deletions

View File

@ -4,11 +4,14 @@
use strict; use strict;
use warnings; use warnings;
use warnings FATAL => 'uninitialized';
my $mpv = $ARGV[0] || 'mpv'; my $mpv = $ARGV[0] || 'mpv';
my @opts = parse_main_opts('--list-options', '^ (\-\-[^\s\*]*)\*?\s*(.*)'); 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 @ao = parse_opts('--ao=help', '^ ([^\s\:]*)\s*: (.*)');
my @vo = parse_opts('--vo=help', '^ ([^\s\:]*)\s*: (.*)'); my @vo = parse_opts('--vo=help', '^ ([^\s\:]*)\s*: (.*)');