Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

nl: unnumbered lines are padded with width+1 spaces, ignoring the length of `-s`

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

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

@cakebaker がすでに取り組んでいます。

2026年10月22日 から。

  • #15619 @cakebaker による — オープン

評価

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

調査の方向性

issueで示された blank_width の計算箇所にある src/uu/nl/src/nl.rs の nl() を読んでください。番号なし行のパディングを、番号付き行に使われる区切り文字の長さと比較し、次に、提示された再現例 nl -s ':-:' と nl -s '' の出力を GNU の出力と比較してください。番号なし行の接頭辞が、数値の幅と区切り文字の長さの合計に一致すれば完了です。デフォルトの TAB の場合も含みます。

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

説明

U - nl

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

環境構築

Codespaces で開く

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

はじめの一歩

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

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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