Skip to content

Conversation

@Xylphy
Copy link
Contributor

@Xylphy Xylphy commented Jan 13, 2026

Closes #10193

This pull request refactors error handling in the tail_file function in src/uu/tail/src/tail.rs to use path.metadata() for file checks and improves error reporting formatting.

Error handling and logic improvements:

  • Changed file existence and directory checks to use path.metadata(), enabling more robust detection of missing files and directories. This replaces separate checks for existence and directory status with a single match statement.
  • Added explicit handling for ErrorKind::NotFound to ensure missing files are reported with the correct error message and observer update, then exit early.

Error reporting formatting:

  • Updated error message formatting to use multi-line translate! calls for better readability and consistency across permission and file opening errors.

@Xylphy Xylphy changed the title Fix(tail): Handle missing/dir paths via metadata() tail: Handle missing/dir paths via metadata() Jan 13, 2026
Add Unix-only tests covering the case where probing a path (e.g. via metadata)
fails with PermissionDenied (directory not searchable). Ensure we report
"Permission denied" rather than "No such file or directory", matching GNU tail.
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/fmt/non-space. tests/fmt/non-space is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tail: exists precheck masks permission errors

1 participant