Skip to content

Accept POSIX attached option-arguments in the CLI - #576

Merged
bertysentry merged 1 commit into
mainfrom
574-cli-attached-option-arguments
Aug 18, 2026
Merged

Accept POSIX attached option-arguments in the CLI#576
bertysentry merged 1 commit into
mainfrom
574-cli-attached-option-arguments

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Fixes #574

What

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 gawk, mawk, BWK awk, and goawk all do through getopt.

How

Cli.parse splits 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 reaches ARGV untouched, 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 with Unknown parameter: -feffects/3d.awk. With this change the demo's command line parses and the program starts.

Tests

  • -fprog.awk loads the script; mixed attached and separate -f forms combine in order.
  • -vx=42 assigns before BEGIN; -F: sets the field separator.
  • An attached-looking operand after -- stays in ARGV; -q2 without program text is still Unknown parameter: -q2.

mvn verify passes: all unit and compatibility tests, checkstyle, PMD, and SpotBugs clean. Documented in cli-reference.md and behavior-changes.md (Unreleased).

🤖 Generated with Claude Code

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>
@bertysentry

Copy link
Copy Markdown
Contributor Author

@codex please review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8e85bd162d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@bertysentry
bertysentry merged commit 83cd519 into main Aug 18, 2026
5 checks passed
@bertysentry
bertysentry deleted the 574-cli-attached-option-arguments branch August 18, 2026 17:04
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.

CLI rejects POSIX attached option-arguments such as -fprog.awk

1 participant