From 7e100a4c161e3b2e8259a6072323ba86c0bab9f7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 19:56:39 +0000 Subject: [PATCH] Fix: Use /system/bin/sh on Android for executing commands. The CommandLineTool.kt was previously hardcoding /bin/bash, which is not available on Android. This change modifies the `runCommand` function to dynamically check the operating system. If the OS is Android, it uses /system/bin/sh; otherwise, it defaults to /bin/bash. This ensures compatibility across different platforms. --- src/main/kotlin/CommandLineTool.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/CommandLineTool.kt b/src/main/kotlin/CommandLineTool.kt index 79a1d72..2424848 100644 --- a/src/main/kotlin/CommandLineTool.kt +++ b/src/main/kotlin/CommandLineTool.kt @@ -69,7 +69,13 @@ fun String.runCommand( timeoutUnit: TimeUnit = TimeUnit.MINUTES, processConfig: ProcessBuilder.() -> Unit = {} ): Process { - ProcessBuilder("/bin/bash", "-c", this).run { + val osName = System.getProperty("os.name") + val shell = if (osName != null && osName.contains("android", ignoreCase = true)) { + "/system/bin/sh" + } else { + "/bin/bash" + } + ProcessBuilder(shell, "-c", this).run { directory(File(".")) inheritIO() processConfig()