aboutsummaryrefslogtreecommitdiff
path: root/go/android/target_sh
diff options
context:
space:
mode:
Diffstat (limited to 'go/android/target_sh')
-rwxr-xr-xgo/android/target_sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/go/android/target_sh b/go/android/target_sh
new file mode 100755
index 00000000..241843e8
--- /dev/null
+++ b/go/android/target_sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e -o pipefail
+
+# Run a command on the target Android device.
+#
+# Usage: target_sh <cmd> <args>...
+
+target="$1"
+shift
+
+exitcode="$(target_tmpdir)/exitcode"
+adb_${target} shell "$*; echo -n \$? > ${exitcode}" | sed -e 's:\r$::' -u
+exit $(adb_${target} shell "cat ${exitcode}")