spring-projects / spring-shell

Spring based shell
http://projects.spring.io/spring-shell/
Apache License 2.0
733 stars 396 forks source link

Can not recognize short-name shell option with multi chars #1109

Open sljdxde opened 3 months ago

sljdxde commented 3 months ago

version: 3.3.1 jdk: openjdk17 issues: 微信截图_20240724102932

I use -hwp 75 as a command, but recognize as -h 75 and -p 75.

I think this may be an issue, or has other configuration to solve?

jvalkeal commented 3 months ago

Thanks for pointing this out. I think we need to revisit how posix style short options are handled.

https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html mentions:

Multiple options may follow a hyphen delimiter in a single token if the options do not take arguments. Thus, -abc is equivalent to -a -b -c.

We have that but we're not that strict as combined "short" option can take a value. This is where you get into trouble. I think at mimimum we could check if all from -a -b -c are defined before interpreting -abc as combined. Might also be nice to have a parser option to turn this feature off completely.

sljdxde commented 3 months ago

Thanks for your response.

I refer to spring-shell website and already known the usage of combined "short" option.

I think I can review the code and give some fix suggestions of the issue recently.

I wonder if I can commit a "pr" of this issue when I find a way to solve it?

jvalkeal commented 3 months ago

Sure any help would be appreciated!