blob: e2d4f9187e35e24d2c278beb65e233222fb55206 [file] [log] [blame]
leozwang@webrtc.org4828e4c2012-10-23 18:34:23 +00001#!/bin/bash
2
3# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
4#
5# Use of this source code is governed by a BSD-style license
6# that can be found in the LICENSE file in the root of the source
7# tree. An additional intellectual property rights grant can be found
8# in the file PATENTS. All contributing project authors may
9# be found in the AUTHORS file in the root of the source tree.
10
11# 'adb shell' always returns "0" regardless of executable return code.
12# This handy script will return executable return code to shell which
13# can be used by buildbots.
14
15adb_shell () {
16 local RET ADB_LOG
17 ADB_LOG=$(mktemp "${TMPDIR:-/tmp}/adb-XXXXXXXX")
leozwang@webrtc.org017ed5c2012-10-23 22:24:56 +000018 adb "$1" "$2" shell "$3" "$4" ";" echo \$? | tee "$ADB_LOG"
leozwang@webrtc.org4828e4c2012-10-23 18:34:23 +000019 sed -i -e 's![[:cntrl:]]!!g' "$ADB_LOG" # Remove \r.
20 RET=$(sed -e '$!d' "$ADB_LOG") # Last line contains status code.
21 rm -f "$ADB_LOG"
22 return $RET
23}