diff options
author | Julien Duraj <julien.duraj@linaro.org> | 2018-02-12 16:09:54 +0000 |
---|---|---|
committer | Julien Duraj <julien.duraj@linaro.org> | 2018-02-12 16:14:47 +0000 |
commit | f5ac3ea0ddcd0ed5364a6b00d8e322bd50851b8b (patch) | |
tree | c25bdcdb40764945e5f6fea13b653bd72221947b | |
parent | 376be27a0835b80c102825903c58613e9f5abbef (diff) |
utils_android: return correct status of adb shell
Use pipefail to get to the actual return of adb shell, which was
previously eaten by piping to `sed`.
Change-Id: Ic843cdfbf0712df1f0133de5e68172009fb6efc1
-rw-r--r-- | utils/utils_android.sh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/utils/utils_android.sh b/utils/utils_android.sh index 74aed48..e01f418 100644 --- a/utils/utils_android.sh +++ b/utils/utils_android.sh @@ -179,15 +179,22 @@ adb_shell() { if [[ ${USE_SUDO:-} == "true" ]]; then cmd="sudo sh -c '$*' 2>/dev/null" fi + # The sed invocation removes leading/trailing whitespaces (including # newlines). # It also removes all CRs (\r). # Whitespaces other than CRs are not affected inside the output (in # particular, internal newlines and horizontal spaces around them are # preserved). + # Since we want to capture the status of `adb shell`, we have to use pipefail. + set -o pipefail adb shell "$cmd" | sed -zE -e 's/^[[:space:]]+//' \ - -e 's/[[:space:]]+$//' \ - -e 's/\r//' + -e 's/[[:space:]]+$//' \ + -e 's/\r//' + local -r ret=$? + set +o pipefail + + return ${ret} } python_runner_exists() { |