Skip to content

fixes a bug in the end-of-options functionality - #18408

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:fix_wrapped_end_of_options
Jun 13, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:fix_wrapped_end_of_options

Conversation

@fdncred

@fdncred fdncred commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug in the end-of-options -- functionality when used with --wrapped. Previously if -- was used with a custom command with --wrapped the code didn't set end_of_options = true properly. So, other --flags=boo would still be passed as flags instead of passing them through.

User-facing changes (Release notes)

Fixed a bug in -- option parsing

Fixed a bug with how -- was handled with --wrapped custom commands. Now you can do things like this:

❯ def --wrapped example [--my-flag: string ...rest] {
  let rest = $rest | skip 1  # skip the '--' delimiter
  $rest | each { {type: ($in | describe) value: $in} } | print
  print $"--my-flag='($my_flag)'"
}
❯ example --my-flag="hi" -- true false 001 --my-flag="goodbye"
╭─#─┬──type──┬───────value───────╮
│ 0 │ string │ true              │
│ 1 │ string │ false             │
│ 2 │ string │ 001               │
│ 3 │ string │ --my-flag=goodbye │
╰───┴────────┴───────────────────╯
--my-flag='hi'

Additional notes

Closes #18399

@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Jun 13, 2026
@github-actions github-actions Bot added A:parser Issues related to parsing and removed notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Jun 13, 2026
@Skyrocket1653

Copy link
Copy Markdown
Contributor

I tried it while it works there are some things I'm not so sure about. The -- is being treated as end of options but at the same time it is being forwarded. I don't believe this is very consistent. In my implementation #18406 where it adds --coerce avoids this inconsistency.

Futhermore, I can avoid boilterplate code:

 let rest = $rest | skip 1 

Is there some reason you want to avoid my implementation?

@fdncred

fdncred commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

It's how --wrapped is supposed to work, it's supposed to pass all arguments through. So, this is a bug fix versus a breaking change.

@Skyrocket1653

Skyrocket1653 commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

The -- isn't a regular argument, it's a control token. Passing it through is inconsistent with also using it to stop flag parsing. If it's truly just "pass everything through", then it shouldn't affect flag parsing either. But it does both, which is the inconsistency.

Either -- means something (end of options, consumed silently) or it's just another string passed through, it's hard to justify both at once.

So --wrapped should stay as is, and a separate flag like --coerce (or named differently) handles this case explicitly.

@fdncred

fdncred commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

We'll have to agree to disagree.

@fdncred fdncred closed this Jun 13, 2026
@fdncred fdncred reopened this Jun 13, 2026
@Skyrocket1653

Copy link
Copy Markdown
Contributor

Hmm, okay I can live with this :(. Though I still think #18406 is worth considering to avoid the skip 1 boilerplate.

@fdncred
fdncred merged commit 8ccbea8 into nushell:main Jun 13, 2026
36 checks passed
@fdncred
fdncred deleted the fix_wrapped_end_of_options branch June 13, 2026 15:56
@github-actions github-actions Bot added this to the v0.114.0 milestone Jun 13, 2026
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:parser Issues related to parsing notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coerce rest into globs

2 participants