summaryrefslogtreecommitdiffstats
path: root/envsetup.sh
diff options
context:
space:
mode:
authorKhalid Zubair <kzubair@cyngn.com>2016-02-02 12:00:14 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-02-03 09:31:46 -0800
commit63eabff2a952c413a33e1ef5a4a6554a73ee6181 (patch)
treec1fc70919c4cece5f5a3ba544e26dd3a00350d13 /envsetup.sh
parent705e90f0903eed0fa2ea92e80b8a5f3f09630cb0 (diff)
downloadbuild-63eabff2a952c413a33e1ef5a4a6554a73ee6181.zip
build-63eabff2a952c413a33e1ef5a4a6554a73ee6181.tar.gz
build-63eabff2a952c413a33e1ef5a4a6554a73ee6181.tar.bz2
envsetup: dopush: fix error when device is not connected
$(adb get-state) was unquoted and returns an empty string when no device is connected causing the if and until statements to be malformed. Fix quoting and refactor the test to a separate function. Change-Id: I2cfa0a7b2033e5a379cab2cae64ed57f5495dbed
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 38f9c6c..6bd6c61 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -2191,6 +2191,19 @@ function repodiff() {
'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;'
}
+# Return success if adb is up and not in recovery
+function _adb_connected {
+ {
+ if [[ "$(adb get-state)" == device &&
+ "$(adb shell test -e /sbin/recovery; echo $?)" == 0 ]]
+ then
+ return 0
+ fi
+ } 2>/dev/null
+
+ return 1
+};
+
# Credit for color strip sed: http://goo.gl/BoIcm
function dopush()
{
@@ -2198,10 +2211,10 @@ function dopush()
shift
adb start-server # Prevent unexpected starting server message from adb get-state in the next line
- if [ $(adb get-state) != device -a $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then
+ if ! _adb_connected; then
echo "No device is online. Waiting for one..."
echo "Please connect USB and/or enable USB debugging"
- until [ $(adb get-state) = device -o $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
+ until _adb_connected; do
sleep 1
done
echo "Device Found."