mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Fix current working directory default value
This commit fixes the issue when `cwd` is empty and is passed to `Runtime.getRuntime().exec(progArray, env, new File(cwd));`, it raises the `No such file or directory` exceptions when targeting sdk `29`.
This commit is contained in:
@@ -36,7 +36,7 @@ public final class BackgroundJob {
|
||||
|
||||
public BackgroundJob(String cwd, String fileToExecute, final String[] args, final TermuxService service, PendingIntent pendingIntent) {
|
||||
String[] env = buildEnvironment(false, cwd);
|
||||
if (cwd == null) cwd = TermuxService.HOME_PATH;
|
||||
if (cwd == null || cwd.isEmpty()) cwd = TermuxService.HOME_PATH;
|
||||
|
||||
final String[] progArray = setupProcessArgs(fileToExecute, args);
|
||||
final String processDescription = Arrays.toString(progArray);
|
||||
@@ -136,7 +136,7 @@ public final class BackgroundJob {
|
||||
static String[] buildEnvironment(boolean failSafe, String cwd) {
|
||||
new File(TermuxService.HOME_PATH).mkdirs();
|
||||
|
||||
if (cwd == null) cwd = TermuxService.HOME_PATH;
|
||||
if (cwd == null || cwd.isEmpty()) cwd = TermuxService.HOME_PATH;
|
||||
|
||||
List<String> environment = new ArrayList<>();
|
||||
|
||||
|
@@ -282,7 +282,7 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
||||
TerminalSession createTermSession(String executablePath, String[] arguments, String cwd, boolean failSafe) {
|
||||
new File(HOME_PATH).mkdirs();
|
||||
|
||||
if (cwd == null) cwd = HOME_PATH;
|
||||
if (cwd == null || cwd.isEmpty()) cwd = HOME_PATH;
|
||||
|
||||
String[] env = BackgroundJob.buildEnvironment(failSafe, cwd);
|
||||
boolean isLoginShell = false;
|
||||
|
Reference in New Issue
Block a user