Skip to content

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