Skip to content

Commit 11fde63

Browse files
authored
du: logic correction for -s option
* The function traverse() takes a directory name param and first does stat() or lstat() depending on other command options * If stat() fails, error is printed, final exit code is set to 1 and the function returns early to avoid printing a total * The same error logic should happen for later opendir() failure, otherwise an unhelpful total will be printed after the error message if the -s option is used * I verified this by forcing opendir to fail
1 parent 8359313 commit 11fde63

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

bin/du

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ sub traverse {
103103
} else {
104104
warn "$0: could not read directory $fn: $!\n";
105105
$rc = EX_FAILURE;
106+
return 0;
106107
}
107108
print "$total\t$fn\n" if $opt_s && $depth == 1;
108109
return $total;

0 commit comments

Comments
 (0)