Skip to content

awk: take the optional value of --lint, --profile and friends only when attached - #201

Open
VanshajPoonia wants to merge 2 commits into
uutils:mainfrom
VanshajPoonia:awk-optional-value-options-181
Open

VanshajPoonia wants to merge 2 commits into
uutils:mainfrom
VanshajPoonia:awk-optional-value-options-181

Conversation

@VanshajPoonia

Copy link
Copy Markdown
Contributor

--lint, --debug, --dump-variables, --pretty-print and --profile take an optional value. clap read the next argument as that value, so awk --lint 'BEGIN { print 1 }' failed with invalid value. gawk only takes the value when it is attached, like --lint=fatal or -Lfatal.

These options now use require_equals, so the help shows --lint[=<LINT>]. That alone broke the attached short form because clap read -Lfatal as -L -f atal. Because of this attach_short_values in src/cli.rs turns -Lfatal into -L=fatal for -d, -D, -L, -o and -p before clap sees it. It stops at the first operand or -- and skips the value after options like -f and -v.

The test from the issue fails on main and passes now. Three more tests keep the attached forms working. cargo test --workspace, clippy with -D warnings and cargo fmt --check pass.

Not handled: a value inside a cluster like -bLfatal. clap reads those the same as before.

Closes #181

…en attached

--lint, --debug, --dump-variables, --pretty-print and --profile took the next argument as their value, so the program text was swallowed. Require the = form in clap and add the = to attached short values (-Lfatal) before parsing, since clap would read those as clusters.
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.

awk: --lint, --profile, --debug, --dump-variables, --pretty-print take the program text as their value

1 participant