fix: exclude echo -n from macos-compat MC002 rule to eliminate false positives (#1545)

The MC002 regex matched both `echo -e` and `echo -n`, but only
`echo -e` is non-portable on macOS bash 3.2. `echo -n` works fine
as a bash builtin. This caused 3 false positive errors (all TTY
probe patterns using `echo -n "" > /dev/tty`) making the linter
exit non-zero incorrectly.

Agent: test-engineer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-20 20:36:47 -08:00 committed by GitHub
parent 031b8fbcf0
commit af475629d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,7 +98,7 @@ while IFS= read -r _f; do
_mc002_msg="'echo"
_mc002_msg="${_mc002_msg} -e' is not portable — use printf instead"
grep_rule "error" "MC002" "$_mc002_msg" \
"$_f" "$_r" 'echo[[:space:]]+-[en]+[[:space:]]'
"$_f" "$_r" 'echo[[:space:]]+-[en]*e[en]*[[:space:]]'
# MC003: source <(...) or . <(...)
grep_rule "error" "MC003" "'source <(...)' fails in bash <(curl...) — use eval instead" \