From 4c69c2cd60d42881b329bebbcaf5ab2726fb1af7 Mon Sep 17 00:00:00 2001 From: w1nst0n Date: Sat, 15 Aug 2020 19:47:59 +0200 Subject: [PATCH] Display a more useful error message when the phone is not detected by ADB (#18) --- debloat_script.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debloat_script.sh b/debloat_script.sh index b8d5699..bd99950 100755 --- a/debloat_script.sh +++ b/debloat_script.sh @@ -3,12 +3,14 @@ # BASH 4.3 or newer is needed ! (use of local -n) (( BASH_VERSINFO < 5 )) && echo "Please upgrade to a bash version >= 4.3" +if ! $(adb get-state &>/dev/null); then echo "Your phone is not detected by ADB." && exit 1; fi + set -euo pipefail # Safer bash script # Colors used for printing readonly BRED='\033[1;31m' # Bold + Red readonly BBLUE='\033[0;34m' # Bold + Blue -readonly BGREEN='\033[1;32m' +readonly BGREEN='\033[1;32m'² readonly BORANGE='\033[1;33m' readonly NC='\033[0m' # No Color readonly Bold=$(tput bold)