mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Fix workdir logic in RunCommandService
This commit fixes the workdir logic to not send `EXTRA_CURRENT_WORKING_DIRECTORY` extra to `TermuxService` if workdir is empty, since that will raise `No such file or directory` exceptions if `cwd` is empty when targeting sdk `29`.
This commit is contained in:
@@ -109,9 +109,13 @@ public class RunCommandService extends Service {
|
|||||||
Intent execIntent = new Intent(TermuxService.ACTION_EXECUTE, programUri);
|
Intent execIntent = new Intent(TermuxService.ACTION_EXECUTE, programUri);
|
||||||
execIntent.setClass(this, TermuxService.class);
|
execIntent.setClass(this, TermuxService.class);
|
||||||
execIntent.putExtra(TermuxService.EXTRA_ARGUMENTS, intent.getStringArrayExtra(RUN_COMMAND_ARGUMENTS));
|
execIntent.putExtra(TermuxService.EXTRA_ARGUMENTS, intent.getStringArrayExtra(RUN_COMMAND_ARGUMENTS));
|
||||||
execIntent.putExtra(TermuxService.EXTRA_CURRENT_WORKING_DIRECTORY, getExpandedTermuxPath(intent.getStringExtra(RUN_COMMAND_WORKDIR)));
|
|
||||||
execIntent.putExtra(TermuxService.EXTRA_EXECUTE_IN_BACKGROUND, intent.getBooleanExtra(RUN_COMMAND_BACKGROUND, false));
|
execIntent.putExtra(TermuxService.EXTRA_EXECUTE_IN_BACKGROUND, intent.getBooleanExtra(RUN_COMMAND_BACKGROUND, false));
|
||||||
|
|
||||||
|
String workingDirectory = intent.getStringExtra(RUN_COMMAND_WORKDIR);
|
||||||
|
if (workingDirectory != null && !workingDirectory.isEmpty()) {
|
||||||
|
execIntent.putExtra(TermuxService.EXTRA_CURRENT_WORKING_DIRECTORY, getExpandedTermuxPath(workingDirectory));
|
||||||
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
this.startForegroundService(execIntent);
|
this.startForegroundService(execIntent);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user