nl: unnumbered lines are padded with width+1 spaces, ignoring the length of `-s`
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
issueで示された blank_width の計算箇所にある src/uu/nl/src/nl.rs の nl() を読んでください。番号なし行のパディングを、番号付き行に使われる区切り文字の長さと比較し、次に、提示された再現例 nl -s ':-:' と nl -s '' の出力を GNU の出力と比較してください。番号なし行の接頭辞が、数値の幅と区切り文字の長さの合計に一致すれば完了です。デフォルトの TAB の場合も含みます。
索引モデルが issue の本文から書いたものです。
説明
For a line that is not numbered (for example an empty line under the default -b t), uutils nl writes number_width + 1 spaces, as if the separator were always the one-byte TAB. With a longer or empty -s STRING, unnumbered lines no longer line up with numbered ones. GNU nl pads with number_width + length(STRING) spaces.
The GNU manual (nl invocation) says:
-s STRING: Separate the line number from the text line in the output with STRING (default is the TAB character).When a line is not numbered, the current line number is not incremented, but the line number separator character is still prepended to the line.
GNU 9.12 keeps the text column aligned: the prefix of an unnumbered line is as wide as the number plus the separator.
printf 'a\n\nb\n' | nl -s ':-:' | sed -n 2p | tr ' ' .
# GNU 9.12: ......... (9 = 6 + 3)
# uutils: ....... (7 = 6 + 1)
printf 'a\n\nb\n' | nl -s '' | sed -n 2p | tr ' ' .
# GNU 9.12: ...... (6)
# uutils: ....... (7)
With the default TAB separator both print 7 spaces.
Versions. uutils main eee56033d28bf7ef5cc816286b048779d57fb803 (2026-10-21) and the 0.12.0 release binary, macOS 26 aarch64 (the loop found it on Linux x86_64), LC_ALL=C, compared with GNU coreutils 9.12.
Where. nl() in src/uu/nl/src/nl.rs: let blank_width = settings.number_width + 1;.
Found with an automated differential tester that compares uutils with GNU 9.12.
Reproduction steps
export LC_ALL=C
printf 'a\n\nb\n' | nl -s ':-:' | cat -A
# GNU 9.12:
# 1:-:a$
# $
# 2:-:b$
# uutils:
# 1:-:a$
# $
# 2:-:b$
- 主要言語
- Rust
- スター
- 24.3k
- フォーク
- 2.1k
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 331
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
uutils/coreutils のほかの issue
-
mv: wrong reason when the source can't be stat'ed (missing 'x/' says Not a directory, EACCES says No such file)対応中かも @emirmrkaljevic が今日担当しました。 オープンU - mv
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
uutils/coreutils#15704 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
U - expand U - unexpand
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
U - sort
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
uutils/coreutils#15598 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
U - sort
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
uutils/coreutils#15596 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
U - sort
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
uutils/coreutils の issue をすべて見る
似ている issue
-
checkpoint/verify/rebuild_indexes on a thread holding a WriteTransaction deadlock instead of INT-001オープンbug known-issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
project-minigraf/minigraf#734 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
Nimblesite/lspkit#26 ·
メンテナーはふだん 1 日以内に返信