Partially revert no init script changes for terminals

This commit is contained in:
crschnick 2023-05-11 10:26:55 +00:00
parent 4bf42831f3
commit f064efaa29

View file

@ -35,7 +35,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Override
protected String toCommand(String name, String file) {
return "-ExecutionPolicy Bypass -NoProfile -Command " + noInit(file);
return "-ExecutionPolicy Bypass -NoProfile -Command cmd /C '" + file + "'";
}
@Override
@ -49,8 +49,8 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Override
protected String toCommand(String name, String file) {
// Fix for https://github.com/PowerShell/PowerShell/issues/18530#issuecomment-1325691850
var script = ScriptHelper.createLocalExecScript("set \"PSModulePath=\"\r\n\"" + noInit(file) + "\"\npause");
return "-ExecutionPolicy Bypass -NoProfile -Command " + noInit(script);
var script = ScriptHelper.createLocalExecScript("set \"PSModulePath=\"\r\n\"" + file + "\"\npause");
return "-ExecutionPolicy Bypass -NoProfile -Command cmd /C '" +script + "'";
}
@Override
@ -68,7 +68,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
// backslash of a filepath to escape the closing quote in the title argument
// So just remove that slash
var fixedName = FileNames.removeTrailingSlash(name);
return "-w 1 nt --title \"" + fixedName + "\" " + noInit(file);
return "-w 1 nt --title \"" + fixedName + "\" \"" + file + "\"";
}
@Override
@ -89,7 +89,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
// In order to fix this bug which also affects us:
// https://askubuntu.com/questions/1148475/launching-gnome-terminal-from-vscode
toExecute =
"GNOME_TERMINAL_SCREEN=\"\" nohup " + noInit(file) + " </dev/null &>/dev/null & disown";
"GNOME_TERMINAL_SCREEN=\"\" nohup " + toExecute + " </dev/null &>/dev/null & disown";
pc.executeSimpleCommand(toExecute);
}
}
@ -109,7 +109,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Override
protected String toCommand(String name, String file) {
return "--new-tab -e " + noInit(file);
return "--new-tab -e \"" + file + "\"";
}
@Override
@ -122,7 +122,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Override
protected String toCommand(String name, String file) {
return "--tab --title \"" + name + "\" --command " + noInit(file);
return "--tab --title \"" + name + "\" --command \"" + file + "\"";
}
@Override
@ -164,10 +164,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
public abstract void launch(String name, String file, boolean elevated) throws Exception;
default String noInit(String file) {
return ShellDialects.getPlatformDefault().executeWithNoInitFiles(ShellDialects.getPlatformDefault(), file);
}
static class MacOsTerminalType extends ExternalApplicationType.MacApplication implements ExternalTerminalType {
public MacOsTerminalType() {
@ -236,7 +232,6 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Override
public void launch(String name, String file, boolean elevated) throws Exception {
var toExecute = noInit(file).replaceAll("\"", "\\\\\"");
try (ShellControl pc = LocalStore.getShell()) {
var cmd = String.format(
"""
@ -257,7 +252,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
end tell
end if
EOF""",
toExecute, toExecute);
file.replaceAll("\"", "\\\\\""), file.replaceAll("\"", "\\\\\""));
pc.executeSimpleCommand(cmd);
}
}