aboutsummaryrefslogtreecommitdiff
path: root/go/android/target_sh
blob: 241843e8abab9e9eef989c8817e9dcb622db013f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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}")