l command: the wrap width comes from the terminal size, and -l is ignored
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the terminal-width and -l cases, then read compile_number_command and output_width() in src/sed/compiler.rs alongside ProcessingContext::length in src/sed/mod.rs. Verify that the l command uses the configured length, defaults to 70, and handles zero consistently, regardless of terminal size.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Rust
- Stars
- 106
- Forks
- 28
- Avg merge
- 14h 12m
- Merged PRs (30d)
- 16
Contributor 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/sed
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
good first issue
Difficulty 4/5 3-5 days Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
good first issue
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100