Attempt to fix zsh issues

This commit is contained in:
crschnick 2023-05-22 13:33:32 +00:00
parent cc1fb789c6
commit 55dc32bacc
4 changed files with 11 additions and 6 deletions

View file

@ -44,7 +44,7 @@ public class ScriptHelper {
}
public static String constructInitFile(
ShellControl processControl, List<String> init, String toExecuteInShell, boolean login, String displayName) {
ShellControl processControl, List<String> init, String toExecuteInShell, boolean login, String displayName) throws Exception {
ShellDialect t = processControl.getShellDialect();
String nl = t.getNewLine().getNewLineString();
var content = String.join(nl, init.stream().filter(s -> s != null).toList()) + nl;
@ -71,7 +71,7 @@ public class ScriptHelper {
content += t.getExitCommand() + nl;
}
var initFile = createExecScript(processControl, content);
var initFile = createExecScript(processControl, t.initFileName(processControl), content);
return initFile;
}
@ -99,7 +99,7 @@ public class ScriptHelper {
}
@SneakyThrows
private static String createExecScript(ShellControl processControl, String file, String content) {
public static String createExecScript(ShellControl processControl, String file, String content) {
ShellDialect type = processControl.getShellDialect();
content = type.prepareScriptContent(content);

View file

@ -14,6 +14,8 @@ import java.util.stream.Stream;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public interface ShellDialect {
String initFileName(ShellControl sc) throws Exception;
CommandControl directoryExists(ShellControl shellControl, String directory);
CommandControl normalizeDirectory(ShellControl shellControl, String directory);

View file

@ -5,6 +5,8 @@ import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellControl;
import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Stream;
public class XPipeTempDirectory {
@ -12,9 +14,10 @@ public class XPipeTempDirectory {
return proc.getOsType().getTempDirectory(proc);
}
public static String getSubDirectory(ShellControl proc) throws Exception {
public static String getSubDirectory(ShellControl proc, String... sub) throws Exception {
var base = proc.getOsType().getTempDirectory(proc);
var dir = FileNames.join(base, "xpipe");
var arr = Stream.concat(Stream.of(base, "xpipe"), Arrays.stream(sub)).toArray(String[]::new);
var dir = FileNames.join(arr);
if (!proc.getShellDialect().createFileExistsCommand(proc, dir).executeAndCheck()) {
proc.executeSimpleCommand(

View file

@ -56,7 +56,7 @@ public class OpenFileWithAction implements LeafAction {
public boolean isApplicable(OpenFileSystemModel model, List<BrowserEntry> entries) {
var os = model.getFileSystem().getShell();
return os.isPresent()
&& !os.get().getOsType().equals(OsType.MACOS)
&& os.get().getOsType().equals(OsType.WINDOWS)
&& entries.size() == 1
&& entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory());
}