diff --git a/core/src/main/java/io/xpipe/core/process/ShellType.java b/core/src/main/java/io/xpipe/core/process/ShellType.java index f7f8abe4..d24c0a2a 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellType.java +++ b/core/src/main/java/io/xpipe/core/process/ShellType.java @@ -3,6 +3,7 @@ package io.xpipe.core.process; import com.fasterxml.jackson.annotation.JsonTypeInfo; import io.xpipe.core.charsetter.NewLine; +import java.io.IOException; import java.nio.charset.Charset; import java.util.List; import java.util.Map; @@ -32,6 +33,8 @@ public interface ShellType { .collect(Collectors.joining(" ")); } + void disableHistory(ShellProcessControl pc) throws Exception; + default String getExitCommand() { return "exit"; } diff --git a/core/src/main/java/io/xpipe/core/process/ShellTypes.java b/core/src/main/java/io/xpipe/core/process/ShellTypes.java index 1c857c75..ad1ef2fe 100644 --- a/core/src/main/java/io/xpipe/core/process/ShellTypes.java +++ b/core/src/main/java/io/xpipe/core/process/ShellTypes.java @@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode; import lombok.Value; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -105,6 +106,10 @@ public class ShellTypes { return "@echo off\n" + content; } + @Override + public void disableHistory(ShellProcessControl pc) throws IOException { + } + @Override public String getExitCodeVariable() { return "errorlevel"; @@ -212,6 +217,11 @@ public class ShellTypes { @Value public static class PowerShell implements ShellType { + @Override + public void disableHistory(ShellProcessControl pc) throws Exception { + pc.executeCommand("Set-PSReadLineOption -HistorySaveStyle SaveNothing"); + } + @Override public String addInlineVariablesToCommand(Map variables, String command) { var content = ""; @@ -449,6 +459,11 @@ public class ShellTypes { return "echo " + prefix + "$" + name; } + @Override + public void disableHistory(ShellProcessControl pc) throws Exception { + pc.executeCommand("unset HISTFILE"); + } + @Override public String getExitCommand() { return "exit 0";