pr: fix column behavior for short files#10379
Merged
sylvestre merged 3 commits intouutils:mainfrom Feb 4, 2026
Merged
Conversation
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Merging this PR will not alter performance
Comparing Footnotes
|
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
would incorrectly produce an output page like this:
After this commit, it produces a more correct output page like this:
In addition to a regression test for this bug, two more unit tests for the
-mbehavior were added. (The-mbehavior is similar to the--columnsbehavior.) These were already passing on themainbranch, and although they are covered by some other test cases, these are more minimal and easier to debug when they fail.