From 185da1b493410a36becdec2c58b6f411edcfee40 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Wed, 21 Oct 2020 20:15:03 +0200 Subject: [PATCH] make find_block() more robust --- CommonInstaller | 6 +++--- patcher/CommonPatcher | 6 +++--- systest/SysTest | 6 +++--- uninstaller/META-INF/com/google/android/update-binary | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CommonInstaller b/CommonInstaller index 28d5c60..9bad7b6 100644 --- a/CommonInstaller +++ b/CommonInstaller @@ -223,8 +223,8 @@ is_mounted () { find_block () { unset tmp tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${1}${SLOT} | head -n 1) - [ -z ${tmp} ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) - if [ -z ${tmp} ]; then + [ -z "${tmp}" ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) + if [ -z "${tmp}" ]; then for uevent in /sys/dev/block/*/uevent; do partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) if [ "${1}${SLOT}" = "${partname}" ]; then @@ -233,7 +233,7 @@ find_block () { fi done fi - readlink -f ${tmp} + readlink -f "${tmp}" } mount_partitions () { diff --git a/patcher/CommonPatcher b/patcher/CommonPatcher index 964e238..c020fb9 100644 --- a/patcher/CommonPatcher +++ b/patcher/CommonPatcher @@ -99,8 +99,8 @@ mount_apex () { find_block () { unset tmp tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${1}${SLOT} | head -n 1) - [ -z ${tmp} ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) - if [ -z ${tmp} ]; then + [ -z "${tmp}" ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) + if [ -z "${tmp}" ]; then for uevent in /sys/dev/block/*/uevent; do partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) if [ "${1}${SLOT}" = "${partname}" ]; then @@ -109,7 +109,7 @@ find_block () { fi done fi - readlink -f ${tmp} + readlink -f "${tmp}" } mount_partitions () { diff --git a/systest/SysTest b/systest/SysTest index 2f0ba04..14942d1 100644 --- a/systest/SysTest +++ b/systest/SysTest @@ -90,8 +90,8 @@ mount_apex () { find_block () { unset tmp tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${1}${SLOT} | head -n 1) - [ -z ${tmp} ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) - if [ -z ${tmp} ]; then + [ -z "${tmp}" ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) + if [ -z "${tmp}" ]; then for uevent in /sys/dev/block/*/uevent; do partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) if [ "${1}${SLOT}" = "${partname}" ]; then @@ -100,7 +100,7 @@ find_block () { fi done fi - readlink -f ${tmp} + readlink -f "${tmp}" } mount_partitions () { diff --git a/uninstaller/META-INF/com/google/android/update-binary b/uninstaller/META-INF/com/google/android/update-binary index 6acf3a9..f5b975a 100644 --- a/uninstaller/META-INF/com/google/android/update-binary +++ b/uninstaller/META-INF/com/google/android/update-binary @@ -115,8 +115,8 @@ error () { find_block () { unset tmp tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${1}${SLOT} | head -n 1) - [ -z ${tmp} ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) - if [ -z ${tmp} ]; then + [ -z "${tmp}" ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1) + if [ -z "${tmp}" ]; then for uevent in /sys/dev/block/*/uevent; do partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) if [ "${1}${SLOT}" = "${partname}" ]; then @@ -125,7 +125,7 @@ find_block () { fi done fi - readlink -f ${tmp} + readlink -f "${tmp}" } mount_partitions () {