Skip to content

feat(lint): add exec-stderr-silence rule — flag 'exec ... 2>/N' persistent stderr suppression#67

Open
olavostauros wants to merge 1 commit into
KnickKnackLabs:mainfrom
olavostauros:feat/exec-stderr-silence
Open

feat(lint): add exec-stderr-silence rule — flag 'exec ... 2>/N' persistent stderr suppression#67
olavostauros wants to merge 1 commit into
KnickKnackLabs:mainfrom
olavostauros:feat/exec-stderr-silence

Conversation

@olavostauros

Copy link
Copy Markdown

Summary

Adds a new lint rule exec-stderr-silence that flags exec with stderr redirection (e.g. exec 3<>"$path" 2>/dev/null). Unlike other commands, exec makes the redirection persist for the current shell, which can silently suppress diagnostic output. Discovered during KnickKnackLabs/notes#15 work.

Detection approach

Text-based pattern matching via bash regex:

  • Matches exec followed by 2>/dev/null, 2>&-, 2>! (noclobber override)
  • Skips full-line comments and rule-specific inline ignores
  • All existing ignore mechanisms supported (repo-level, file-level, inline with reason)

Files

  • .mise/tasks/lint/exec-stderr-silence — task implementation (67 lines of logic)
  • test/lint/exec-stderr-silence/exec-stderr-silence.bats — 17 BATS tests
  • test/lint/exec-stderr-silence/fixtures/ — 7 fixture scenarios

Validation

  • mise run test — all 17 tests pass
  • codebase lint:exec-stderr-silence .mise/tasks/lint/exec-stderr-silence — self-hosting passes (task doesn't self-report)
  • git diff --check — clean

…r suppression

Adds text-based detection for 'exec' with stderr redirection
(2>/dev/null, 2>&-, 2>!) that persists for the current shell.

- Detection via bash regex: \bexec\b[^#]*2> with dangerous target
- Fixtures: clean, dirty, ignored-inline, ignored-file, broad-walk, no-toml, empty
- 17 BATS tests covering detection, ignore mechanisms, discovery, edge cases
- Self-hosting verified: task file does not self-report
- Follows or-true pattern for output format, ignore conventions, and scope
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