use brackets for correct operator precedence when using grep

This commit is contained in:
Johannes 'josch' Schauer 2018-09-23 15:26:47 +02:00
parent fe060e6cad
commit ee60b2c7e3
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -355,10 +355,22 @@ sub havemknod($) {
die "/test-dev-null already exists"; die "/test-dev-null already exists";
} }
while ($havemknod == 0) { while ($havemknod == 0) {
last unless 0 == system 'mknod', "$root/test-dev-null", 'c', '1', '3'; # we fork so that we can read STDERR
last unless -c "$root/test-dev-null"; my $pid = open my $fh, '-|' // die "failed to fork(): $!";
last unless open my $fh, '>', "$root/test-dev-null"; if ($pid == 0) {
last unless print $fh 'test'; open(STDERR, '>&', STDOUT);
# we use mknod(1) instead of the system call because creating the
# right dev_t argument requires makedev(3)
exec 'mknod', "$root/test-dev-null", 'c', '1', '3';
}
chomp (my $content = do { local $/; <$fh> });
close $fh;
{
last unless $? == 0 and $content eq '';
last unless -c "$root/test-dev-null";
last unless open my $fh, '>', "$root/test-dev-null";
last unless print $fh 'test';
}
$havemknod = 1; $havemknod = 1;
} }
if (-e "$root/test-dev-null") { if (-e "$root/test-dev-null") {
@ -480,7 +492,7 @@ sub setup {
} }
open my $fh, '>', "$options->{root}/etc/apt/sources.list" or die "cannot open /etc/apt/sources.list: $!"; open my $fh, '>', "$options->{root}/etc/apt/sources.list" or die "cannot open /etc/apt/sources.list: $!";
if (scalar(@{$options->{mirrors}}) > 0) { if (scalar(@{$options->{mirrors}}) > 0) {
if( grep /^-$/, @{$options->{mirrors}} > 1 ) { if((grep /^-$/, @{$options->{mirrors}}) > 1 ) {
die "can only read from stdin once"; die "can only read from stdin once";
} }
for my $arg (@{$options->{mirrors}}) { for my $arg (@{$options->{mirrors}}) {