From 41786d99cda85402d92854417fabde542452cf66 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 8 Oct 2024 00:22:39 +0000 Subject: [PATCH] Fix NPE --- .../io/xpipe/ext/base/script/SimpleScriptStore.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java index 85ed87dfc..d1e251b73 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStore.java @@ -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); @@ -45,9 +49,9 @@ public class SimpleScriptStore extends ScriptStore implements ShellInitCommand.T 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())); @@ -77,7 +81,7 @@ public class SimpleScriptStore extends ScriptStore implements ShellInitCommand.T 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")); } }