Various fixes [stage]

This commit is contained in:
crschnick
2024-06-26 12:16:06 +00:00
parent 7f0d9746d1
commit 9d4903e665
26 changed files with 76 additions and 42 deletions
@@ -55,7 +55,7 @@ public class RunScriptAction implements BrowserAction, BranchAction {
continue;
}
if (script.assemble(sc) == null) {
if (!script.isCompatible(sc)) {
continue;
}
@@ -32,15 +32,20 @@ public class SimpleScriptStore extends ScriptStore implements ShellInitCommand.T
private final boolean shellScript;
private final boolean fileScript;
public String assemble(ShellControl shellControl) {
public boolean isCompatible(ShellControl shellControl) {
var targetType = shellControl.getOriginalShellDialect();
if (minimumDialect.isCompatibleTo(targetType)) {
return minimumDialect.isCompatibleTo(targetType);
}
public String assemble(ShellControl shellControl) {
if (isCompatible(shellControl)) {
var shebang = commands.startsWith("#");
// Fix new lines and shebang
var fixedCommands = commands.lines()
.skip(shebang ? 1 : 0)
.collect(Collectors.joining(
shellControl.getShellDialect().getNewLine().getNewLineString()));
var targetType = shellControl.getOriginalShellDialect();
var script = ScriptHelper.createExecScript(targetType, shellControl, fixedCommands);
return targetType.sourceScriptCommand(shellControl, script.toString());
}