Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tr: generate an error if the input is a directory #6855

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sylvestre
Copy link
Contributor

tested by tests/misc/read-errors

tested by tests/misc/read-errors
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)

Comment on lines +17 to +19
fn test_invalid_input() {
new_ucmd!().args(&["1", "1", "<", "."]).fails().code_is(1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes even without applying the other changes. So I would also check for the error message.

while let Ok(length) = input.read_until(b'\n', &mut buf) {
loop {
let length = match input.read_until(b'\n', &mut buf) {
Ok(0) => break, // EOF reached
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line makes the break on line 600 unreachable. So I would either remove this line (and probably you can get rid of the match, too) or remove the if and the if-case on lines 599 - 601.

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.

2 participants