From b559d5a0bda866e8df0b241fe2c4f06fca416fcc Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Sat, 23 Oct 2021 04:20:16 +0500 Subject: [PATCH] Fixed: Fix TermuxService failing to execute files with "#" am startservice --user 0 -n com.termux/.app.TermuxService -a com.termux.service_execute -d "file:///data/data/com.termux/files/home/te#st.sh" --- app/src/main/java/com/termux/app/TermuxService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/termux/app/TermuxService.java b/app/src/main/java/com/termux/app/TermuxService.java index 0b3baaa6..141ebdaf 100644 --- a/app/src/main/java/com/termux/app/TermuxService.java +++ b/app/src/main/java/com/termux/app/TermuxService.java @@ -26,6 +26,7 @@ import com.termux.app.settings.properties.TermuxAppSharedProperties; import com.termux.app.terminal.TermuxTerminalSessionClient; import com.termux.app.utils.PluginUtils; import com.termux.shared.data.IntentUtils; +import com.termux.shared.data.UriUtils; import com.termux.shared.models.errors.Errno; import com.termux.shared.shell.ShellUtils; import com.termux.shared.termux.shell.TermuxShellEnvironmentClient; @@ -360,7 +361,10 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas executionCommand.inBackground = intent.getBooleanExtra(TERMUX_SERVICE.EXTRA_BACKGROUND, false); if (executionCommand.executableUri != null) { - executionCommand.executable = executionCommand.executableUri.getPath(); + Logger.logVerbose(LOG_TAG, "uri: \"" + executionCommand.executableUri + "\", path: \"" + executionCommand.executableUri.getPath() + "\", fragment: \"" + executionCommand.executableUri.getFragment() + "\""); + + // Get full path including fragment (anything after last "#") + executionCommand.executable = UriUtils.getUriFilePath(executionCommand.executableUri); executionCommand.arguments = IntentUtils.getStringArrayExtraIfSet(intent, TERMUX_SERVICE.EXTRA_ARGUMENTS, null); if (executionCommand.inBackground) executionCommand.stdin = IntentUtils.getStringExtraIfSet(intent, TERMUX_SERVICE.EXTRA_STDIN, null);