nl: unnumbered lines are padded with width+1 spaces, ignoring the length of `-s`
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Read nl() in src/uu/nl/src/nl.rs at the blank_width calculation identified in the issue. Compare the padding for unnumbered lines with the separator length used for numbered lines, then run the provided nl -s ':-:' and nl -s '' reproductions against GNU output. Done when the unnumbered line prefix matches the number width plus the separator length, including the default TAB case.
Written by the indexing model from the issue text.
Description
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$
- Dominant language
- Rust
- Stars
- 24.3k
- Forks
- 2.1k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 331
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uutils/coreutils
-
U - sort
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
uutils/coreutils#15598 · 3 comments ·
Maintainers usually reply within 1 day
-
U - sort
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
uutils/coreutils#15596 · 3 comments ·
Maintainers usually reply within 1 day
-
U - sort
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
U - sort
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Maintainers usually reply within 1 day
-
sort: `-b` and `-M` still skip leading form feed and carriage return (follow-up to #14119)Possibly taken @ozenyunus35 claimed this today. OpenU - sort
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
All issues in uutils/coreutils
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
foxglove/mcap#1907 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
good first issue help wanted r-feature
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
servo/rust-smallvec#792 ·
Maintainers usually reply within 1 day
-
A-Unicode C-bug P-low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
rust-lang/rustfmt#7210 · 1 comment ·
Maintainers usually reply within 1 day
-
callTracer with withLog: true includes logs from a reverted top-level call (diverges from geth)Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
paradigmxyz/revm-inspectors#570 ·
Maintainers usually reply within 1 day