Skip to content

Commit

Permalink
tail: warn for directory args
Browse files Browse the repository at this point in the history
* The -f mode of tail calls tail_f(), passing file & directory arguments as separate params
* By default handle_args() loops over Files list, not Dirs list, so directory arguments were silently ignored
* Make the default case follow GNU tail and print a warning for each directory argument, and exit with error code
  • Loading branch information
mknos authored Oct 21, 2023
1 parent 46f6023 commit d271149
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/tail
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,13 @@ sub handle_args($$$)
my @dirs;

for my $f (@$files_) {
if(-d $f) {
push @dirs, $f;
if (-d $f) {
if ($opt_f) {
push @dirs, $f;
} else {
warn "$me: '$f' is a directory\n";
$rc = EX_FAILURE;
}
} else {
push @files, $f;
}
Expand Down

0 comments on commit d271149

Please sign in to comment.