diff --git a/app/src/main/java/com/termux/app/RunCommandService.java b/app/src/main/java/com/termux/app/RunCommandService.java
index 9bc1326a..59b52b14 100644
--- a/app/src/main/java/com/termux/app/RunCommandService.java
+++ b/app/src/main/java/com/termux/app/RunCommandService.java
@@ -210,6 +210,8 @@ public class RunCommandService extends Service {
if(!executionCommand.setState(ExecutionState.PRE_EXECUTION))
return Service.START_NOT_STICKY;
+
+
// If "allow-external-apps" property to not set to "true", then just return
errmsg = PluginUtils.checkIfRunCommandServiceAllowExternalAppsPolicyIsViolated(this);
if (errmsg != null) {
@@ -218,6 +220,16 @@ public class RunCommandService extends Service {
return Service.START_NOT_STICKY;
}
+
+
+ // If executable is null or empty, then exit here instead of getting canonical path which would expand to "/"
+ if (executionCommand.executable == null || executionCommand.executable.isEmpty()) {
+ errmsg = this.getString(R.string.error_run_command_service_mandatory_extra_missing, RUN_COMMAND_SERVICE.EXTRA_COMMAND_PATH);
+ executionCommand.setStateFailed(ExecutionCommand.RESULT_CODE_FAILED, errmsg, null);
+ PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand);
+ return Service.START_NOT_STICKY;
+ }
+
// Get canonical path of executable
executionCommand.executable = FileUtils.getCanonicalPath(executionCommand.executable, null, true);
@@ -233,6 +245,8 @@ public class RunCommandService extends Service {
return Service.START_NOT_STICKY;
}
+
+
// If workingDirectory is not null or empty
if (executionCommand.workingDirectory != null && !executionCommand.workingDirectory.isEmpty()) {
// Get canonical path of workingDirectory
@@ -255,6 +269,8 @@ public class RunCommandService extends Service {
}
}
+
+
executionCommand.executableUri = new Uri.Builder().scheme(TERMUX_SERVICE.URI_SCHEME_SERVICE_EXECUTE).path(FileUtils.getExpandedTermuxPath(executionCommand.executable)).build();
Logger.logVerbose(LOG_TAG, executionCommand.toString());
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 14b4392f..dc1e5c68 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -87,6 +87,7 @@
Invalid intent action to RunCommandService: `%1$s`
+ Mandatory extra missing to RunCommandService: \"%1$s\"
RunCommandService require `allow-external-apps` property to be set to `true` in `&TERMUX_PROPERTIES_PRIMARY_PATH_SHORT;` file.
Visit https://github.com/termux/termux-app/blob/master/app/src/main/java/com/termux/app/RunCommandService.java for more info on RUN_COMMAND Intent usage.