pr: -n repeats line numbers after a form feed

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

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

まだ誰も着手していません。

評価

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

調査の方向性

バグは src/uu/pr/src/pr.rs の 1153-1156 行目付近にある get_pages にあります。フォームフィード分岐は line_num を増やさずに FileLine を追加しますが、改行分岐は 1183 行目付近で line_num を増やします。cargo build --locked -p uu_pr の後に printf 'a\fb\nc\n' | target/debug/pr -T -n:1 で再現します。出力が GNU と同じく 1:a、2:b、3:c となり、末尾の改行の有無や -N10 の指定にかかわらず -n の番号付けが正しく保たれれば完了です。

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

説明

U - pr

pr -n does not advance the line counter when a form feed ends a line. The next line receives the same number, and later line numbers are too small.

Reproduced on Linux x86_64 (Debian 13), using uutils 0.13.0 from main at 43eb6205c20c551480057cdee98e6e7529cd984d, with LC_ALL=C LANG=C. GNU coreutils 9.12 (the reference package linked in CONTRIBUTING.md) and 9.7 both produce the expected result.

From the repository root:

cargo build --locked -p uu_pr
export LC_ALL=C LANG=C
printf 'a\fb\nc\n' | target/debug/pr -T -n:1

Actual output:

1:a
1:b
2:c

Expected output (GNU 9.12 and 9.7):

1:a
2:b
3:c

Both exit 0 with empty stderr. -T removes pagination, making the numbering difference visible without headers or page separators.

The problem also occurs without a trailing newline and with -N10. With a\fb\fc\n, all three lines receive number 1. As controls, a\nb\nc\n and a\n\fb\nc\n produce 1, 2, 3 in both implementations.

In get_pages, pr.rs:1153–1156, the form-feed branch pushes a FileLine without incrementing line_num. The newline branch increments it at line 1183.

No matching report was found in searches of open and closed issues and related PRs for pr numbering and form feeds. Existing #12313 and #14334 describe column formatting and page padding, rather than repeated line numbers.

主要言語
Rust
スター
24.3k
フォーク
2.1k
平均マージ
1日 22時間
マージ済み PR(30日)
396

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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