mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Shell encoding fixes [release]
This commit is contained in:
parent
f777352dbe
commit
97079fb58d
7 changed files with 44 additions and 23 deletions
|
@ -27,10 +27,6 @@ public class SentryErrorHandler {
|
|||
options.setProguardUuid(AppProperties.get().getBuildUuid().toString());
|
||||
options.setTag("os", System.getProperty("os.name"));
|
||||
});
|
||||
|
||||
var user = new User();
|
||||
user.setId(AppCache.getCachedUserId().toString());
|
||||
Sentry.setUser(user);
|
||||
}
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
|
||||
|
@ -95,6 +91,11 @@ public class SentryErrorHandler {
|
|||
s.setTag("message", ee.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var user = new User();
|
||||
user.setId(AppCache.getCachedUserId().toString());
|
||||
s.setUser(user);
|
||||
}
|
||||
|
||||
private static Breadcrumb toBreadcrumb(TrackEvent te) {
|
||||
|
|
|
@ -21,7 +21,7 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
|||
}
|
||||
};
|
||||
|
||||
public static final ExternalEditorType VSCODE = new WindowsFullPathType("app.vscode") {
|
||||
public static final ExternalEditorType VSCODE_WINDOWS = new WindowsFullPathType("app.vscode") {
|
||||
|
||||
@Override
|
||||
protected Optional<Path> determinePath() {
|
||||
|
@ -31,6 +31,11 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
|||
.resolve("bin")
|
||||
.resolve("code.cmd"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean detach() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
public static final ExternalEditorType NOTEPADPLUSPLUS_WINDOWS = new WindowsFullPathType("app.notepad++") {
|
||||
|
||||
|
@ -129,6 +134,10 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
|||
super(id);
|
||||
}
|
||||
|
||||
public boolean detach() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(Path file) throws Exception {
|
||||
var path = determinePath();
|
||||
|
@ -139,11 +148,11 @@ public interface ExternalEditorType extends PrefsChoiceValue {
|
|||
ApplicationHelper.executeLocalApplication(
|
||||
sc -> String.format(
|
||||
"%s %s", sc.getShellDialect().fileArgument(path.get().toString()), sc.getShellDialect().fileArgument(file.toString())),
|
||||
true);
|
||||
detach());
|
||||
}
|
||||
}
|
||||
|
||||
public static final List<ExternalEditorType> WINDOWS_EDITORS = List.of(VSCODE, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD);
|
||||
public static final List<ExternalEditorType> WINDOWS_EDITORS = List.of(VSCODE_WINDOWS, NOTEPADPLUSPLUS_WINDOWS, NOTEPAD);
|
||||
public static final List<LinuxPathType> LINUX_EDITORS =
|
||||
List.of(VSCODE_LINUX, KATE, GEDIT, PLUMA, LEAFPAD, MOUSEPAD);
|
||||
public static final List<ExternalEditorType> MACOS_EDITORS = List.of(VSCODE_MACOS, SUBLIME_MACOS, TEXT_EDIT);
|
||||
|
|
|
@ -152,7 +152,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
|
|||
@Override
|
||||
public void launch(String name, String command) throws Exception {
|
||||
try (ShellControl pc = LocalStore.getShell()) {
|
||||
var suffix = command.equals(pc.getShellDialect().getNormalOpenCommand())
|
||||
var suffix = command.equals(pc.getShellDialect().getOpenCommand())
|
||||
? "\"\""
|
||||
: "\"" + command.replaceAll("\"", "\\\\\"") + "\"";
|
||||
var cmd = "osascript -e 'tell app \"" + "Terminal" + "\" to do script " + suffix + "'";
|
||||
|
|
|
@ -52,13 +52,15 @@ public class ScriptHelper {
|
|||
public static String constructInitFile(
|
||||
ShellControl processControl, List<String> init, String toExecuteInShell) {
|
||||
ShellDialect t = processControl.getShellDialect();
|
||||
if (init.size() == 0 && toExecuteInShell == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// We always want to generate and init file
|
||||
// if (init.size() == 0 && toExecuteInShell == null) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
if (init.size() == 0) {
|
||||
// Check for special case of the command to be executed just being another shell script
|
||||
if (toExecuteInShell.endsWith(".sh") || toExecuteInShell.endsWith(".bat")) {
|
||||
if (toExecuteInShell != null && (toExecuteInShell.endsWith(".sh") || toExecuteInShell.endsWith(".bat"))) {
|
||||
return toExecuteInShell;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ShellControl extends ProcessControl {
|
||||
|
||||
|
@ -72,21 +73,28 @@ public interface ShellControl extends ProcessControl {
|
|||
SecretValue getElevationPassword();
|
||||
|
||||
default ShellControl subShell(@NonNull ShellDialect type) {
|
||||
return subShell(p -> type.getNormalOpenCommand(), (shellProcessControl, s) -> {
|
||||
return s == null ? type.getNormalOpenCommand() : type.executeCommandWithShell(s);
|
||||
})
|
||||
.elevationPassword(getElevationPassword());
|
||||
return subShell(p -> type.getOpenCommand(), null).elevationPassword(getElevationPassword());
|
||||
}
|
||||
|
||||
default ShellControl subShell(@NonNull List<String> command) {
|
||||
return subShell(
|
||||
shellProcessControl -> shellProcessControl.getShellDialect().flatten(command), null);
|
||||
default ShellControl identicalSubShell() {
|
||||
return subShell(p -> p.getShellDialect().getOpenCommand(), null)
|
||||
.elevationPassword(getElevationPassword());
|
||||
}
|
||||
|
||||
default ShellControl subShell(@NonNull String command) {
|
||||
return subShell(processControl -> command, null);
|
||||
}
|
||||
|
||||
default <T> T enforceDialect(@NonNull ShellDialect type, Function<ShellControl, T> sc) throws Exception {
|
||||
if (isRunning() && getShellDialect().equals(type)) {
|
||||
return sc.apply(this);
|
||||
} else {
|
||||
try (var sub = subShell(type).start()) {
|
||||
return sc.apply(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShellControl subShell(
|
||||
FailableFunction<ShellControl, String, Exception> command,
|
||||
FailableBiFunction<ShellControl, String, String, Exception> terminalCommand);
|
||||
|
@ -110,7 +118,8 @@ public interface ShellControl extends ProcessControl {
|
|||
}
|
||||
|
||||
default CommandControl command(List<String> command) {
|
||||
return command(shellProcessControl -> shellProcessControl.getShellDialect().flatten(command));
|
||||
return command(
|
||||
shellProcessControl -> shellProcessControl.getShellDialect().flatten(command));
|
||||
}
|
||||
|
||||
void exitAndWait() throws IOException;
|
||||
|
|
|
@ -91,9 +91,9 @@ public interface ShellDialect {
|
|||
return getPrintVariableCommand(name);
|
||||
}
|
||||
|
||||
String getNormalOpenCommand();
|
||||
String getOpenCommand();
|
||||
|
||||
String prepareInitFileOpenCommand(ShellControl parent, String file);
|
||||
String prepareTerminalInitFileOpenCommand(ShellControl parent, String file) throws Exception;
|
||||
|
||||
String runScript(String file);
|
||||
|
||||
|
|
2
version
2
version
|
@ -1 +1 @@
|
|||
0.5.20
|
||||
0.5.21
|
Loading…
Reference in a new issue