Skip to content

join: fix -1 X and -2 Y explicit field numbers - #1053

Merged
briandfoy merged 1 commit into
briandfoy:masterfrom
mknos:join-explicit-fields
Sep 3, 2026
Merged

join: fix -1 X and -2 Y explicit field numbers#1053
briandfoy merged 1 commit into
briandfoy:masterfrom
mknos:join-explicit-fields

Conversation

@mknos

@mknos mknos commented Sep 2, 2026

Copy link
Copy Markdown
Contributor
  • Default field number is 1 for file1 and file2; this is designated by variable $j1 and $j2 being initialised to zero
  • This is meant to be equivalent to join -j 1, which sets $j1 and $j2 to the same thing
  • This is also supposed to be equivalent to join -1 1 -2 1
  • Fix off-by-one error where the field number returned by get_numeric_arg() is not decremented (internally the field values are zero based)
  • This issue was flagged by MS-365-Copilot analysis of the program, and patched by me
  • Save the regex capture into a named variable to help clarify that it's talking about a file number and not a field number
  • Bump version
  • Tested against GNU coreutils

Test: before patch

%perl cat TAB1
AA xyz MR_BOB
XX asd MR_FRED
%perl cat TAB2
AA Friendly
BB Extinct
XX Grumpy
%/usr/bin/join --version
join (uutils coreutils) 0.8.0
%/usr/bin/join TAB{1,2}
AA xyz MR_BOB Friendly
XX asd MR_FRED Grumpy
%perl join TAB{1,2}
AA xyz MR_BOB Friendly
XX asd MR_FRED Grumpy
%/usr/bin/join -1 1 -2 1 TAB{1,2}
AA xyz MR_BOB Friendly
XX asd MR_FRED Grumpy
%perl join  -1 1 -2 1 TAB{1,2}
%perl join  -1 0 -2 0 TAB{1,2}
fields start at 1
join (Perl Power Tools) 1.1
usage: join [-a file_number | -v file_number] [-e string] [-j file_number field]
            [-o list] [-t char] [-1 field] [-2 field] file1 file2

* Default field number is 1 for file1 and file2; this is designated by variable $j1 and $j2 being initialised to zero
* This is meant to be equivalent to `join -j 1`, which sets $j1 and $j2 to the same thing
* This is also supposed to be equivalent to `join -1 1 -2 1`
* Fix off-by-one error where the field number returned by get_numeric_arg() is not decremented (internally the field values are zero based)
* This issue was flagged by analysis by MS-365-Copilot and patched by me
* Save the regex capture into a named variable to help clarify that it's talking about a file number and not a field number
* Bump version
* Tested against GNU coreutils
@mknos
mknos deployed to housekeeping September 2, 2026 09:38 — with GitHub Actions Active
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@mknos
mknos temporarily deployed to automated_testing September 2, 2026 09:38 — with GitHub Actions Inactive
@github-actions github-actions Bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: join The join program Status: needs verification issue needs to be verified Type: bug an existing feature does not work labels Sep 2, 2026
@briandfoy briandfoy removed the Type: enhancement improve a feature that already exists label Sep 3, 2026
@briandfoy briandfoy removed the Status: needs verification issue needs to be verified label Sep 3, 2026
Comment thread bin/join
@briandfoy
briandfoy merged commit 528774f into briandfoy:master Sep 3, 2026
23 of 24 checks passed
@briandfoy
briandfoy deployed to housekeeping September 3, 2026 17:08 — with GitHub Actions Active
@briandfoy

Copy link
Copy Markdown
Owner

changes: fix increment bug in setting the two default offsets to the wrong things.

@github-actions github-actions Bot added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Program: join The join program Status: accepted The fix is accepted Type: bug an existing feature does not work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants