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

NonInteractiveShellRunner cause command parse failed #1151

Open
yumc1991 opened this issue Nov 28, 2024 · 2 comments
Open

NonInteractiveShellRunner cause command parse failed #1151

yumc1991 opened this issue Nov 28, 2024 · 2 comments
Labels
status/need-feedback Calling participant to provide feedback

Comments

@yumc1991
Copy link

NonInteractiveShellRunner

  • Version: SpringShell 3.3.1

  • Desc:
    I use nonInteractive mode, but find the default runner may change my origin command and concat """ to my command, which may cause command parse failed.

I don't know why the runner need to do this, and I fix it by using String raw = String.join(" ", args); instead.

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Nov 28, 2024
@corneil
Copy link

corneil commented Dec 12, 2024

Shouldn't it be return Collections.singletonList(this.primaryCommand);?

I would suggest you paste code sample in a block with starting with
```java
void somecode() {
}
// and close with
```

@corneil corneil added status/need-feedback Calling participant to provide feedback and removed status/need-triage Team needs to triage and take a first look labels Dec 12, 2024
@yumc1991
Copy link
Author

Cause my project is in Citrix, I can not copy my code directly.

Here are the code snippets.

The Origin code is below:

// origin code, which may cause command parse failed
String raw = (String) Arrays.stream(args).map((a) -> {
    return !isQuoted(a) && StringUtils.containsWhitespace(a) ? "\"" + a "\"" : a;
 }).collect(Collectors.joining(" "));

The fixed version is below:

// fixed version
String raw = String.join(" ", args);

By doing this, my command in noninteractive like java -jar xxx-spring-shell.jar -c "get -s set -k key" can execute correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/need-feedback Calling participant to provide feedback
Projects
None yet
Development

No branches or pull requests

2 participants