diff options
author | Philip Sequeira <phsequei@gmail.com> | 2015-07-03 18:01:36 -0400 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-19 22:04:45 +0200 |
commit | 2cf019ed707391759828cf1d4e81f1b235d95bc7 (patch) | |
tree | a58756bcb0ee8d0ecb3a341dff29e71256404903 /TOOLS/zsh.pl | |
parent | 47a62059a92c711be90fb6b2de456b965128fdc2 (diff) | |
download | mpv-2cf019ed707391759828cf1d4e81f1b235d95bc7.tar.bz2 mpv-2cf019ed707391759828cf1d4e81f1b235d95bc7.tar.xz |
TOOLS/zsh.pl: die loudly if mpv fails to run
Diffstat (limited to 'TOOLS/zsh.pl')
-rwxr-xr-x | TOOLS/zsh.pl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/TOOLS/zsh.pl b/TOOLS/zsh.pl index 6548d85d12..91b15bbde5 100755 --- a/TOOLS/zsh.pl +++ b/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; +} |