Skip to content

rm: match GNU compat edge cases - #751

Merged
ewhauser merged 2 commits into
mainfrom
ewhauser/rm-gnu-compat
Mar 27, 2026
Merged

ewhauser merged 2 commits into
mainfrom
ewhauser/rm-gnu-compat

Conversation

@ewhauser

Copy link
Copy Markdown
Owner

Summary

  • align rm with GNU compat behavior for empty operands, ignorable -f lookups, unreadable empty directories, write-protected prompts, and top-level trailing-slash verbose output
  • add focused rm regressions for the newly covered compat cases
  • tighten runtime TTY detection so redirected character devices like /dev/null do not look interactive

Verification

  • 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=1
  • make gnu-test GNU_UTILS=rm GNU_KEEP_WORKDIR=1
  • make lint

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread internal/runtime/virtual_tty.go Resolved
@ewhauser
ewhauser merged commit 72a633c into main Mar 27, 2026
15 checks passed
@ewhauser
ewhauser deleted the ewhauser/rm-gnu-compat branch March 27, 2026 03:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +112 to 115
if fd, ok := reader.(interface{ Fd() uintptr }); ok {
descriptor := fd.Fd()
return descriptor != 0 && term.IsTerminal(int(descriptor))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread internal/builtins/rm.go
Comment on lines +630 to +633
if fd, ok := reader.(interface{ Fd() uintptr }); ok {
descriptor := fd.Fd()
return descriptor != 0 && term.IsTerminal(int(descriptor))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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.

1 participant