mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Use BackgroundJob.setupProcessArgs for sessions
This commit is contained in:
@@ -242,8 +242,8 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
|||||||
if (cwd == null) cwd = HOME_PATH;
|
if (cwd == null) cwd = HOME_PATH;
|
||||||
|
|
||||||
String[] env = BackgroundJob.buildEnvironment(failSafe, cwd);
|
String[] env = BackgroundJob.buildEnvironment(failSafe, cwd);
|
||||||
|
boolean isLoginShell = false;
|
||||||
|
|
||||||
String shellName;
|
|
||||||
if (executablePath == null) {
|
if (executablePath == null) {
|
||||||
File shell = new File(HOME_PATH, ".termux/shell");
|
File shell = new File(HOME_PATH, ".termux/shell");
|
||||||
if (shell.exists()) {
|
if (shell.exists()) {
|
||||||
@@ -274,23 +274,18 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
|||||||
// Fall back to system shell as last resort:
|
// Fall back to system shell as last resort:
|
||||||
executablePath = "/system/bin/sh";
|
executablePath = "/system/bin/sh";
|
||||||
}
|
}
|
||||||
|
isLoginShell = true;
|
||||||
String[] parts = executablePath.split("/");
|
|
||||||
shellName = "-" + parts[parts.length - 1];
|
|
||||||
} else {
|
|
||||||
int lastSlashIndex = executablePath.lastIndexOf('/');
|
|
||||||
shellName = lastSlashIndex == -1 ? executablePath : executablePath.substring(lastSlashIndex + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] args;
|
String[] processArgs = BackgroundJob.setupProcessArgs(executablePath, arguments);
|
||||||
if (arguments == null) {
|
executablePath = processArgs[0];
|
||||||
args = new String[]{shellName};
|
int lastSlashIndex = executablePath.lastIndexOf('/');
|
||||||
} else {
|
String processName = (isLoginShell ? "-" : "") +
|
||||||
args = new String[arguments.length + 1];
|
(lastSlashIndex == -1 ? executablePath : executablePath.substring(lastSlashIndex + 1));
|
||||||
args[0] = shellName;
|
|
||||||
|
|
||||||
System.arraycopy(arguments, 0, args, 1, arguments.length);
|
String[] args = new String[processArgs.length];
|
||||||
}
|
args[0] = processName;
|
||||||
|
if (processArgs.length > 1) System.arraycopy(processArgs, 1, args, 1, processArgs.length - 1);
|
||||||
|
|
||||||
TerminalSession session = new TerminalSession(executablePath, cwd, args, env, this);
|
TerminalSession session = new TerminalSession(executablePath, cwd, args, env, this);
|
||||||
mTerminalSessions.add(session);
|
mTerminalSessions.add(session);
|
||||||
|
Reference in New Issue
Block a user