You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
grep - with -m 0 still opens files instead of short-circuiting like GNU (errors on a missing file GNU never touches) #4
GNU grep treats -m 0 / --max-count=0 as "stop before reading any line": it
never opens the input file at all, so a nonexistent file produces no error and
the run exits 1 (no match). uu_grep opens the file first and only then
applies the max-count, so a missing file yields a No such file or directory
error and exit 2.
Rust (incorrect - errors on the missing file)
$ ./target/release/grep -e x -m 0 /no/such/file
grep: /no/such/file: No such file or directory (os error 2)
# Exit code: 2
GNU (correct - short-circuits, never opens the file)
$ LC_ALL=C /usr/bin/grep -e x -m 0 /no/such/file
# (no output)# Exit code: 1
Scope
The divergence is specific to -m 0. With -m 1 on the same missing file
both implementations error and exit 2.
On an existing file, -m 0 already behaves correctly in both (no output,
exit 1) — only the file-opening side effect differs.
Activity