Repository navigation
rm: match GNU compat edge cases - #751
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4886287265
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1abc3446f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if fd, ok := reader.(interface{ Fd() uintptr }); ok { | ||
| descriptor := fd.Fd() | ||
| return descriptor != 0 && term.IsTerminal(int(descriptor)) | ||
| } |
There was a problem hiding this comment.
Treat fd 0 as a valid terminal in TTY detection
readerLooksLikeTTY now returns from the Fd() branch before checking Stat(), but the new condition rejects descriptor 0. For real terminal input, os.Stdin uses fd 0, so bindExecutionTTY will classify an interactive stdin as non-TTY and skip wiring execution /dev/tty. That breaks terminal-backed /dev/tty behavior for normal CLI executions where stdin is an *os.File terminal.
Useful? React with 👍 / 👎.
| if fd, ok := reader.(interface{ Fd() uintptr }); ok { | ||
| descriptor := fd.Fd() | ||
| return descriptor != 0 && term.IsTerminal(int(descriptor)) | ||
| } |
There was a problem hiding this comment.
Allow rm to recognize tty stdin on descriptor 0
rmInputIsTTY uses the same descriptor != 0 && term.IsTerminal(...) check, so stdin on fd 0 is always treated as non-interactive. In default rm mode this suppresses write-protected prompts even when the command is run from a real terminal, which is a behavior regression and can lead to unintended deletions without confirmation.
Useful? React with 👍 / 👎.
Summary
rmwith GNU compat behavior for empty operands, ignorable-flookups, unreadable empty directories, write-protected prompts, and top-level trailing-slash verbose outputrmregressions for the newly covered compat cases/dev/nulldo not look interactiveVerification
go test ./internal/builtins -run 'Test(ParseRMSpec|RM)'go test ./internal/runtime -run 'TestReaderLooksLikeTTY'make gnu-test GNU_TESTS=tests/rm/empty-inacc.sh GNU_KEEP_WORKDIR=1make gnu-test GNU_UTILS=rm GNU_KEEP_WORKDIR=1make lint