Skip to content

Commit

Permalink
Fix: if from STDIN, print always to STDOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
hknutzen committed Jan 22, 2017
1 parent 55ee2ac commit 4882560
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
11 changes: 3 additions & 8 deletions bin/add-to-netspoc
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,7 @@ sub process {
last;
}
}

if ($changed) {
return ($changed, $copy);
}
else {
return ();
}
return ($changed, $copy);
}

sub process_file {
Expand All @@ -245,7 +239,8 @@ sub process_file {
# Undef input record separator to read all output at once.
{ local $/ = undef; $input = <$in>; }
close $in;
if (my ($count, $copy) = process($input)) {
my ($count, $copy) = process($input);
if ($count or $path eq '-') {
info "$count changes in $path" if not $quiet;
if ($path ne '-') {
unlink($path) or fatal_err "Can't remove $path: $!\n";
Expand Down
11 changes: 3 additions & 8 deletions bin/remove-from-netspoc
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,7 @@ sub process {
last;
}
}

if ($changed) {
return ($changed, $copy);
}
else {
return ();
}
return ($changed, $copy);
}

sub process_file {
Expand All @@ -275,7 +269,8 @@ sub process_file {
# Undef input record separator to read all output at once.
{ local $/ = undef; $input = <$in>; }
close $in;
if (my ($count, $copy) = process($input)) {
my ($count, $copy) = process($input);
if ($count or $path eq '-') {
info "$count changes in $path" if not $quiet;
if ($path ne '-') {
unlink($path) or fatal_err "Can't remove $path: $!\n";
Expand Down

0 comments on commit 4882560

Please sign in to comment.