mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 23:50:32 +00:00
More shell fixes
This commit is contained in:
parent
453ccd5d14
commit
2133e2322f
3 changed files with 18 additions and 22 deletions
|
@ -64,8 +64,8 @@ public interface ShellProcessControl extends ProcessControl {
|
|||
SecretValue getElevationPassword();
|
||||
|
||||
default ShellProcessControl subShell(@NonNull ShellType type) {
|
||||
return subShell(p -> type.openCommand(), (shellProcessControl, s) -> {
|
||||
return s == null ? type.openCommand() : type.switchTo(s);
|
||||
return subShell(p -> type.getNormalOpenCommand(), (shellProcessControl, s) -> {
|
||||
return s == null ? type.getNormalOpenCommand() : type.executeCommandWithShell(s);
|
||||
})
|
||||
.elevation(getElevationPassword());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public interface ShellType {
|
|||
|
||||
String createInitFileContent(String command);
|
||||
|
||||
String getOpenWithInitFileCommand(String file);
|
||||
String getFileOpenCommand(String file);
|
||||
|
||||
default String flatten(List<String> command) {
|
||||
return command.stream()
|
||||
|
@ -48,10 +48,6 @@ public interface ShellType {
|
|||
return ";";
|
||||
}
|
||||
|
||||
default String getAndConcatenationOperator() {
|
||||
return "&&";
|
||||
}
|
||||
|
||||
default String getOrConcatenationOperator() {
|
||||
return "||";
|
||||
}
|
||||
|
@ -74,9 +70,9 @@ public interface ShellType {
|
|||
|
||||
String getPrintVariableCommand(String prefix, String name);
|
||||
|
||||
String openCommand();
|
||||
String getNormalOpenCommand();
|
||||
|
||||
String switchTo(String cmd);
|
||||
String executeCommandWithShell(String cmd);
|
||||
|
||||
List<String> createMkdirsCommand(String dirs);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ShellTypes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getOpenWithInitFileCommand(String file) {
|
||||
public String getFileOpenCommand(String file) {
|
||||
return String.format("%s %s \"%s\"", getExecutable(), "/C", file);
|
||||
}
|
||||
|
||||
|
@ -139,12 +139,12 @@ public class ShellTypes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String openCommand() {
|
||||
public String getNormalOpenCommand() {
|
||||
return "cmd";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String switchTo(String cmd) {
|
||||
public String executeCommandWithShell(String cmd) {
|
||||
return "cmd.exe /C " + cmd + "";
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ public class ShellTypes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getOpenWithInitFileCommand(String file) {
|
||||
public String getFileOpenCommand(String file) {
|
||||
return String.format("%s -ExecutionPolicy Bypass -File \"%s\"", getExecutable(), file);
|
||||
}
|
||||
|
||||
|
@ -319,12 +319,12 @@ public class ShellTypes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String openCommand() {
|
||||
public String getNormalOpenCommand() {
|
||||
return "powershell /nologo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String switchTo(String cmd) {
|
||||
public String executeCommandWithShell(String cmd) {
|
||||
return "powershell.exe -Command '" + cmd + "'";
|
||||
}
|
||||
|
||||
|
@ -422,7 +422,7 @@ public class ShellTypes {
|
|||
|
||||
@Override
|
||||
public String getPauseCommand() {
|
||||
return "read -n1 -r -p \"Press any key to continue ...\" key";
|
||||
return "read -rsp \"Press any key to continue...\\n\" -n 1 key";
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
@ -448,8 +448,8 @@ public class ShellTypes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getOpenWithInitFileCommand(String file) {
|
||||
return String.format("%s -i -l -c \"%s\"", getExecutable(), file);
|
||||
public String getFileOpenCommand(String file) {
|
||||
return String.format("%s -i -c \"%s\"", getExecutable(), file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -490,13 +490,13 @@ public class ShellTypes {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String openCommand() {
|
||||
return getName() + " -i -l";
|
||||
public String getNormalOpenCommand() {
|
||||
return getName() + " -i";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String switchTo(String cmd) {
|
||||
return getName() + " -i -l -c '" + cmd + "'";
|
||||
public String executeCommandWithShell(String cmd) {
|
||||
return getName() + " -i -c '" + cmd + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue