Skip to content

pr: fix column behavior for short files#10379

Merged
sylvestre merged 3 commits intouutils:mainfrom
jfinkels:pr-columns
Feb 4, 2026
Merged

pr: fix column behavior for short files#10379
sylvestre merged 3 commits intouutils:mainfrom
jfinkels:pr-columns

Conversation

@jfinkels
Copy link
Collaborator

@jfinkels jfinkels commented Jan 20, 2026

Fix a bug where lines of the input file were not correctly distributed
to the columns of the output page if there were fewer lines than the
total number of cells in the output table. For example, before this
commit,

printf "a\nb\n" | pr -2

would incorrectly produce an output page like this:

a
b

After this commit, it produces a more correct output page like this:

a    b

In addition to a regression test for this bug, two more unit tests for the -m behavior were added. (The -m behavior is similar to the --columns behavior.) These were already passing on the main branch, and although they are covered by some other test cases, these are more minimal and easier to debug when they fail.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/dd/stderr is no longer failing!
Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!
Congrats! The gnu test tests/tail/follow-stdin is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/shuf/shuf-reservoir (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/sort/sort-stale-thread-mem (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 20, 2026

Merging this PR will not alter performance

✅ 142 untouched benchmarks
⏩ 180 skipped benchmarks1


Comparing jfinkels:pr-columns (8168563) with main (938039e)

Open in CodSpeed

Footnotes

  1. 180 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@jfinkels jfinkels marked this pull request as ready for review January 20, 2026 05:58
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/dd/stderr is no longer failing!
Congrats! The gnu test tests/tac/tac-2-nonseekable is no longer failing!
Congrats! The gnu test tests/tail/follow-stdin is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/retry. tests/tail/retry is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/printf/printf-surprise is now passing!

Add a passing unit tests for `pr` for merging two files.
Factor out helper functions for grouping a flat list of lines from the
input file(s) into a two-dimensional table representing the columnar
layout of the output page. Command-line options affect how the lines are
grouped, so there are different helper functions for each of the various
behaviors.
Fix a bug where lines of the input file were not correctly distributed
to the columns of the output page if there were fewer lines than the
total number of cells in the output table. For example, before this
commit,

    printf "a\nb\n" | pr -2

would incorrectly produce an output page like this:

    a
    b

After this commit, it produces a more correct output page like this:

    a    b
@sylvestre sylvestre merged commit a5aa2a8 into uutils:main Feb 4, 2026
131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants