* Don't continue when the call to nix fails.

This commit is contained in:
Eelco Dolstra 2003-08-25 14:36:04 +00:00
parent a88144215c
commit 920193beb1
1 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,8 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
use strict;
use IPC::Open2;
my $linkdir = "@localstatedir@/nix/links"; my $linkdir = "@localstatedir@/nix/links";
my $storedir = "@prefix@/store"; my $storedir = "@prefix@/store";
@ -16,13 +19,18 @@ foreach my $arg (@ARGV) {
my $extraarg = ""; my $extraarg = "";
if ($keepsuccessors) { $extraarg = "--include-successors"; }; if ($keepsuccessors) { $extraarg = "--include-successors"; };
open HASHES, "nix --query --requisites $extraarg \$(cat $linkdir/*.id) |" or die "in `nix -qrh'"; my $pid = open2(\*READ, \*WRITE, "nix --query --requisites $extraarg \$(cat $linkdir/*.id)")
while (<HASHES>) { or die "determining live paths";
close WRITE;
while (<READ>) {
chomp; chomp;
$alive{$_} = 1; $alive{$_} = 1;
if ($invert) { print "$_\n"; }; if ($invert) { print "$_\n"; };
} }
close HASHES; close READ;
waitpid $pid, 0;
$? == 0 or die "determining live paths";
exit 0 if ($invert); exit 0 if ($invert);