~vila/ubuntu-test-cases/retry-apt-get-update

« back to all changes in this revision

Viewing changes to utils/host/adb-shell

  • Committer: Leo Arias
  • Date: 2014-11-10 19:28:56 UTC
  • mfrom: (345 touch)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: leo.arias@canonical.com-20141110192856-rgpksx9n9j0b39yl
Merged with the touch branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# The "adb shell" command doesn't return an error if the command you execute
 
4
# resulted in an error. This is a wrapper to return the command's true return code.
 
5
 
 
6
# NOTE: This script uses some specific bash'isms to keep things short and simple
 
7
 
 
8
set -eu
 
9
 
 
10
pat='ADB_RC=([[:digit:]]+)'
 
11
 
 
12
{
 
13
        if ! adb shell "$* ; echo ADB_RC=\$?" ; then
 
14
                adb wait-for-device
 
15
                adb shell "$* ; echo ADB_RC=\$?"
 
16
        fi
 
17
} | while read line; do
 
18
        echo $line
 
19
        if [[ $line =~ $pat ]] ; then
 
20
                rc=${BASH_REMATCH[1]}
 
21
                exit $rc
 
22
        fi
 
23
done