Skip to content

Commit

Permalink
Merge pull request #5155 from cakebaker/nl_no_renumber
Browse files Browse the repository at this point in the history
nl: re-add handling for -p/--no-renumber
  • Loading branch information
tertsdiepraam authored Aug 12, 2023
2 parents 9e739f1 + 08e21e1 commit f53c073
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/uu/nl/src/nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ fn nl<T: Read>(reader: &mut BufReader<T>, settings: &Settings) -> UResult<()> {

if let Some(new_style) = new_numbering_style {
current_numbering_style = new_style;
line_no = settings.starting_line_number;
if settings.renumber {
line_no = settings.starting_line_number;
}
println!();
} else {
let is_line_numbered = match current_numbering_style {
Expand Down
6 changes: 5 additions & 1 deletion tests/by-util/test_nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ fn test_sections_and_styles() {
#[test]
fn test_no_renumber() {
for arg in ["-p", "--no-renumber"] {
new_ucmd!().arg(arg).succeeds();
new_ucmd!()
.arg(arg)
.pipe_in("a\n\\:\\:\nb")
.succeeds()
.stdout_is(" 1\ta\n\n 2\tb\n");
}
}

Expand Down

0 comments on commit f53c073

Please sign in to comment.