zsh.pl: fail if no curl is found

Instead of generation a broken completion file.
This commit is contained in:
Alessandro Ghedini 2015-12-27 18:12:46 +01:00 committed by Daniel Stenberg
parent 5d7c9379ef
commit 92a20413ac
1 changed files with 13 additions and 2 deletions

View File

@ -38,7 +38,7 @@ sub parse_main_opts {
my ($cmd, $regex) = @_;
my @list;
my @lines = split /\n/, `"$curl" $cmd`;
my @lines = call_curl($cmd);
foreach my $line (@lines) {
my ($short, $long, $arg, $desc) = ($line =~ /^$regex/) or next;
@ -74,4 +74,15 @@ sub parse_main_opts {
return @list;
}
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
sub call_curl {
my ($cmd) = @_;
my $output = `"$curl" $cmd`;
if ($? == -1) {
die "Could not run curl: $!";
} elsif ((my $exit_code = $? >> 8) != 0) {
die "curl returned $exit_code with output:\n$output";
}
return split /\n/, $output;
}