Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix "--" handling when interspersed is false #359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slushie
Copy link

@slushie slushie commented Feb 11, 2025

This PR fixes an issue introduced when handling -- with app.Interspersed(false) set. The issue is caused by returning the -- as an argument token instead of skipping it. The change reorders the return code path, so that passing -- sets p.argsOnly = true and then subsequently returns p.Next(), rather than return the arg directly.

I discovered this when upgrading from v2.2.6 to v2.4.0. Previously, the -- token was always skipped by ParseContext.Next. This change reverts the behavior in 2.4.0 to match that of 2.2.6 -- after which it seems to have been accidentally changed. I've also included test cases to validate this behavior going forward.

For comparison, in v2.2.6 the relevant code is:

	// All remaining args are passed directly.
	if arg == "--" {
		p.argsOnly = true
		return p.Next()
	}

Thanks for your consideration!

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.

1 participant