Skip to content

Support for bare double dash in argument parsing with SimpleCommandLineArgsParser [SPR-17416] #21949

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

Closed
spring-projects-issues opened this issue Oct 20, 2018 · 1 comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Oct 20, 2018

Phil Webb opened SPR-17416 and commented

Originally raise as a Spring Boot issue:

I would like Spring Boot application to support guideline 10 of POSIX.1-2017 - Utility argument convention section:

The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.

The desired behavior is to recognize the -- and leave all the arguments to the right of it alone.

Just for context: in 2.0.x passing -- to a SpringBoot application results in an error (sample trace below). The double dash is treated as an invalid option (whose name is zero-length) and there seems to be no way to configure this behavior.

java.lang.IllegalArgumentException: Invalid argument syntax: --
	at org.springframework.core.env.SimpleCommandLineArgsParser.parse(SimpleCommandLineArgsParser.java:75)
	at org.springframework.core.env.SimpleCommandLinePropertySource.<init>(SimpleCommandLinePropertySource.java:90)
	at org.springframework.boot.DefaultApplicationArguments$Source.<init>(DefaultApplicationArguments.java:76)
	at org.springframework.boot.DefaultApplicationArguments.<init>(DefaultApplicationArguments.java:42)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
	at com.netflix.genie.GenieAgentApplication.run(GenieAgentApplication.java:63)

Reference URL: spring-projects/spring-boot#14909

@spring-projects-issues spring-projects-issues added status: waiting-for-triage An issue we've not yet triaged or decided on type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) and removed type: enhancement A general enhancement labels Jan 11, 2019
@bclozel
Copy link
Member

bclozel commented Oct 27, 2023

Closing in favor of #31513

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
@bclozel bclozel added status: superseded An issue that has been superseded by another type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 27, 2023
bclozel added a commit to bclozel/spring-framework that referenced this issue Nov 6, 2023
Prior to this commit, the `SimpleCommandLineArgsParser` would reject
"--" arguments as invalid. As reported by the community, the POSIX
utility conventions (Guideline 10) state that

> The first -- argument that is not an option-argument should be
> accepted as a delimiter indicating the end of options.
> Any following arguments should be treated as operands, even if they
> begin with the '-' character.

This commit updates `SimpleCommandLineArgsParser` to not reject "--"
arguments and instead to consider remaining arguments as non-optional.

Fixes spring-projectsgh-21949
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants