Skip to content

base32/base64/basenc: accept a -w value starting with - to match GNU - #14084

Open
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:base-wrap-hyphen-value
Open

base32/base64/basenc: accept a -w value starting with - to match GNU#14084
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:base-wrap-hyphen-value

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

base64 -w -5 (and any -w value that starts with -, e.g. -w -d) was rejected by the argument parser with unexpected argument '-5' found, while GNU takes the token after -w as the wrap size and reports invalid wrap size:

$ printf abc | base64 -w -5
error: unexpected argument '-5' found
$ printf abc | gbase64 -w -5
gbase64: invalid wrap size: '-5'

Adding allow_hyphen_values(true) to the -w/--wrap argument lets the value reach the existing wrap-size parser, which already emits the GNU-matching message. Verified against GNU for -w -5, -w -d, -w -x (all invalid wrap size), with valid values (-w 5, -w0, --wrap=5) and decoding unchanged. The shared base_common.rs covers base32, base64 and basenc.

@codspeed-hq

codspeed-hq Bot commented Aug 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 178 untouched benchmarks
⏩ 229 skipped benchmarks1


Comparing AlejandroCoronadoN:base-wrap-hyphen-value (78daa23) with main (a9b64fc)2

Open in CodSpeed

Footnotes

  1. 229 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.

  2. No successful run was found on main (71ebb92) during the generation of this report, so a9b64fc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/dd/no-allocate is now passing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!

.short('w')
.long(options::WRAP)
.value_name("COLS")
// GNU takes the token after -w as the wrap size even when it starts with '-'.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// GNU takes the token after -w as the wrap size even when it starts with '-'.

Comment is unnecessary if you added test.

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.

3 participants