Accept POSIX attached option-arguments in the CLI - #576
Merged
Conversation
The value-taking short options -f, -v, -F, -L, -K, and -l now accept their value attached to the option letter (-fprog.awk, -vx=1, -F:), as every other AWK implementation does through getopt. The argument is split into the option and its value before dispatch, so option processing boundaries (--, first operand, unknown option after the program text) are unaffected. Fixes #574 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@codex please review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Fixes #574
What
The value-taking short options
-f,-v,-F,-L,-K, and-lnow accept their value attached to the option letter —-fprog.awk,-vx=1,-F:— as gawk, mawk, BWK awk, and goawk all do through getopt.How
Cli.parsesplits an attached option-argument into the option and its value before dispatching, so the existing option branches and all option-processing boundaries (--, first operand, unknown option after the program text) behave exactly as before. Arguments that already ended option processing are never split: an attached form after--still reachesARGVuntouched, and an unknown glued option (-q2) is still rejected when no program text was supplied.Why
Real-world scripts build command lines this way. patsie75/awk-demo assembles its effects with the bash expansion
"${effects[@]/#/-f}", producing-feffects/3d.awk -feffects/fire.awk ..., which Jawk rejected withUnknown parameter: -feffects/3d.awk. With this change the demo's command line parses and the program starts.Tests
-fprog.awkloads the script; mixed attached and separate-fforms combine in order.-vx=42assigns beforeBEGIN;-F:sets the field separator.--stays inARGV;-q2without program text is stillUnknown parameter: -q2.mvn verifypasses: all unit and compatibility tests, checkstyle, PMD, and SpotBugs clean. Documented incli-reference.mdandbehavior-changes.md(Unreleased).🤖 Generated with Claude Code