grep - `-L` with `-m 0` or `-v ''` prints nothing; GNU still lists every file

オープン 初心者向け
#213 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@yunusarda-sudo がすでに取り組んでいます。

2026年11月17日 から。

  • #216 @yunusarda-sudo による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
83/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
cli, testing

調査の方向性

issueでは uu_grep の早期終了が指摘され、Rustの回帰テストも含まれていますが、ソースファイルやテストファイルのパスは示されていません。まずその早期終了箇所と、-L に関する既存のgrepテストを探してください。提示された -m 0 と -v -e '' のケースを追加し、読み取り可能なファイルが一覧表示される一方で終了コードが1のままであることを確認してください。GNUの skip-read ケースについても、-G、-E、-F でテストが必要です。

索引モデルが issue の本文から書いたものです。

説明

bug gnu-compat good first issue

When no line can be selected (-m 0, or -v with an empty pattern) uu_grep exits 1 before
opening any file. That is right for plain output, -c, -l and -q, but not for
-L/--files-without-match: every file then has no selected line, and GNU grep lists each
readable file (and still reports files it cannot open). uu_grep prints nothing.

Exposed by the GNU test skip-read (grep -L -m0 y /dev/null and grep -L -v "" /dev/null must print /dev/null, with -G, -E and -F).

Reproduction

$ printf 'red\n' > colors

Rust (incorrect)

$ ./target/release/grep -L -m 0 red colors
# Output: (none)
# Exit code: 1

$ ./target/release/grep -L -v -e '' colors
# Output: (none)
# Exit code: 1

GNU (correct)

$ LC_ALL=C /usr/bin/grep -L -m 0 red colors
colors
# Exit code: 1

$ LC_ALL=C /usr/bin/grep -L -v -e '' colors
colors
# Exit code: 1

$ LC_ALL=C /usr/bin/grep -L -m 0 red colors nosuch
colors
/usr/bin/grep: nosuch: No such file or directory
# Exit code: 2

Test

#[test]
fn files_without_match_with_nothing_selectable() {
    for args in [&["-L", "-m", "0", "pine"][..], &["-L", "-v", "-e", ""][..]] {
        let (scene, mut c) = ucmd();
        scene.fixtures.write("trees.txt", "pine\noak\n");
        c.args(args)
            .arg("trees.txt")
            .fails_with_code(1)
            .stdout_only("trees.txt\n");
    }
}

Exposed by the GNU grep test suite: skip-read.

主要言語
Rust
スター
147
フォーク
34
平均マージ
3日 18時間
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

uutils/grep のほかの issue

uutils/grep の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。