Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
crschnick committed Oct 8, 2024
1 parent 89b245a commit 41786d9
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class SimpleScriptStore extends ScriptStore implements ShellInitCommand.T
private final boolean fileScript;
private final boolean runnableScript;

public String getCommands() {
return commands != null ? commands : "";
}

public boolean isCompatible(ShellControl shellControl) {
var targetType = shellControl.getOriginalShellDialect();
return minimumDialect.isCompatibleTo(targetType);
Expand All @@ -45,9 +49,9 @@ public boolean isCompatible(ShellDialect dialect) {

private String assembleScript(ShellControl shellControl) {
if (isCompatible(shellControl)) {
var shebang = commands.startsWith("#");
var shebang = getCommands().startsWith("#");
// Fix new lines and shebang
var fixedCommands = commands.lines()
var fixedCommands = getCommands().lines()
.skip(shebang ? 1 : 0)
.collect(Collectors.joining(
shellControl.getShellDialect().getNewLine().getNewLineString()));
Expand Down Expand Up @@ -77,7 +81,7 @@ public void checkComplete() throws Throwable {
Validators.nonNull(group);
super.checkComplete();
Validators.nonNull(minimumDialect);
if (!initScript && !shellScript && !fileScript && !isRunnableScript()) {
if (!initScript && !shellScript && !fileScript && !runnableScript) {
throw new ValidationException(AppI18n.get("app.valueMustNotBeEmpty"));
}
}
Expand Down

0 comments on commit 41786d9

Please sign in to comment.