Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

l command: the wrap width comes from the terminal size, and -l is ignored

Aperta
#551 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@SichenLiang ci sta già lavorando.

Dal 8/9/2026.

  • #552 di @SichenLiang — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

Inizia riproducendo i casi relativi alla larghezza del terminale e a -l, quindi leggi compile_number_command e output_width() in src/sed/compiler.rs insieme a ProcessingContext::length in src/sed/mod.rs. Verifica che il comando l usi la lunghezza configurata, abbia 70 come valore predefinito e gestisca lo zero in modo coerente, indipendentemente dalle dimensioni del terminale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The wrap width used by the l command does not come from the -l option or from its documented default. It comes from the width of the terminal the process happens to be running in, and falls back to 60 when there is no terminal. The same command on the same input therefore produces different bytes depending on where the output goes, and changes when the window is resized.

Tested with uutils sed 0.2.0 built from main at 77f442d, against GNU sed 4.9, under LC_ALL=C.

Measured under a pty of an explicit width, input 200 x, length of the first output line:

terminal columns 20 40 80 120 200
GNU sed 4.9 70 70 70 70 70
uutils sed 20 40 80 120 200

-l N is parsed and then ignored:

$ printf 'aaaaaaaaaa\n' | sed -n -l 5 l
aaaa\
aaaa\
aa$

$ printf 'aaaaaaaaaa\n' | ./target/release/sed -n -l 5 l
aaaaaaaaaa$

-l 5, -l 0 and -l 200 all produce the same output.

l 0 folds after every character:

$ echo abc | sed -n 'l 0'
abc$

$ echo abc | ./target/release/sed -n 'l 0'
\
a\
b\
c$

With no terminal, the default width is 60 rather than 70:

$ printf 'a%.0s' {1..70} | sed -n l
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
a$

$ printf 'a%.0s' {1..70} | ./target/release/sed -n l
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\
aaaaaaaaaaa$

The GNU sed manual, on -l N: "A length of 0 (zero) means to never wrap long lines. If not specified, it is taken to be 70." On the l n argument: "a length of 0 (zero) means to never wrap long lines. If omitted, the default as specified on the command line is used."

compile_number_command in src/sed/compiler.rs stores output_width() when l has no numeric argument, and output_width() reads terminal_size(). The value from -l is already computed correctly into ProcessingContext::length in src/sed/mod.rs (defaulting to 70) and is never read.

I have a fix for this and will open a PR.

Lingua principale
Rust
Stelle
110
Fork
36
Merge medio
1g 23h
PR unite (30g)
30

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di uutils/sed

Tutte le issue di uutils/sed

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.