mirror of
https://github.com/mpv-player/mpv
synced 2025-01-09 00:19:32 +00:00
TOOLS/zsh.pl: die loudly if mpv fails to run
This commit is contained in:
parent
47a62059a9
commit
2cf019ed70
15
TOOLS/zsh.pl
15
TOOLS/zsh.pl
@ -141,7 +141,7 @@ sub parse_main_opts {
|
||||
my ($cmd, $regex) = @_;
|
||||
|
||||
my @list;
|
||||
my @lines = split /\n/, `"$mpv" --no-config $cmd`;
|
||||
my @lines = call_mpv($cmd);
|
||||
|
||||
foreach my $line (@lines) {
|
||||
my ($name, $desc) = ($line =~ /^$regex/) or next;
|
||||
@ -206,7 +206,7 @@ sub parse_opts {
|
||||
my ($cmd, $regex) = @_;
|
||||
|
||||
my @list;
|
||||
my @lines = split /\n/, `"$mpv" --no-config $cmd`;
|
||||
my @lines = call_mpv($cmd);
|
||||
|
||||
foreach my $line (@lines) {
|
||||
if ($line !~ /^$regex/) {
|
||||
@ -226,3 +226,14 @@ sub parse_opts {
|
||||
|
||||
return @list;
|
||||
}
|
||||
|
||||
sub call_mpv {
|
||||
my ($cmd) = @_;
|
||||
my $output = `"$mpv" --no-config $cmd`;
|
||||
if ($? == -1) {
|
||||
die "Could not run mpv: $!";
|
||||
} elsif ($? != 0) {
|
||||
die "mpv returned " . ($? >> 8) . " with output:\n$output";
|
||||
}
|
||||
return split /\n/, $output;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user