- # push @cmd, @{$cmd_opt->{-default}} if $cmd_opt->{-default};
- for my $bool (qw(rsyncable)) {
- my $switch = $cmd_opt->{rsyncable} // next;
+
+ # not all gzip support --rsyncable, FreeBSD gzip doesn't even exit
+ # with an error code
+ if (!$decompress && $cmd[0] =~ m!/gzip\z! && !defined($cmd_opt)) {
+ pipe(my ($r, $w)) or die "pipe: $!";
+ open my $null, '+>', '/dev/null' or die "open: $!";
+ my $rdr = { 0 => $null, 1 => $null, 2 => $w };
+ my $tst = [ $cmd[0], '--rsyncable' ];
+ my $pid = PublicInbox::Spawn::spawn($tst, undef, $rdr);
+ close $w;
+ my $err = do { local $/; <$r> };
+ waitpid($pid, 0) == $pid or die "BUG: waitpid: $!";
+ $cmd_opt = $err ? {} : { rsyncable => '' };
+ push(@$x, $cmd_opt);
+ }
+ for my $bool (keys %$cmd_opt) {
+ my $switch = $cmd_opt->{$bool} // next;