summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorWill McVicker <willmcvicker@google.com>2024-05-06 10:37:16 -0700
committerWill McVicker <willmcvicker@google.com>2024-05-06 10:37:16 -0700
commit986e73f10f1db4ef3731186905518dff1f341588 (patch)
tree4aff3a7b23e7c5b7afe7abe4bbe842681fbc6dfa /tools
parent5809ec2a674c4e3d47b5430e208d422286eb382f (diff)
downloadextras-986e73f10f1db4ef3731186905518dff1f341588.tar.gz
tools/check_elf_alignment.sh: Use double quotes
When files have spaces in them, we need to use double quotes. Otherwise some of the bash commands like `basename` and `mktemp` don't use the full filename which results in incorrect behavior. Bug: 337895632 Change-Id: Ia50946051bd8ef6cff460810d3559f98d55731c6 Signed-off-by: Will McVicker <willmcvicker@google.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/check_elf_alignment.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/check_elf_alignment.sh b/tools/check_elf_alignment.sh
index 4183c790..b74f34ae 100755
--- a/tools/check_elf_alignment.sh
+++ b/tools/check_elf_alignment.sh
@@ -40,12 +40,12 @@ if ! [ -f "${dir}" -o -d "${dir}" ]; then
exit 1
fi
-if [[ ${dir} == *.apk ]]; then
+if [[ "${dir}" == *.apk ]]; then
trap 'cleanup_trap' EXIT
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
echo "=== APK zip-alignment ==="
- zipalign -v -c -P 16 4 ${dir} | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
+ zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
echo "========================="
else
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
@@ -55,10 +55,10 @@ if [[ ${dir} == *.apk ]]; then
echo " sdkmanager \"build-tools;35.0.0-rc3\""
fi
- dir_filename=$(basename ${dir})
- tmp=$(mktemp -d -t ${dir_filename%.apk}_out_XXXXX)
- unzip ${dir} lib/* -d ${tmp} >/dev/null 2>&1
- dir=${tmp}
+ dir_filename=$(basename "${dir}")
+ tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
+ unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
+ dir="${tmp}"
fi
RED="\e[31m"
@@ -70,7 +70,7 @@ unaligned_libs=()
echo
echo "=== ELF alignment ==="
-matches="$(find ${dir} -name "*.so" -type f)"
+matches="$(find "${dir}" -name "*.so" -type f)"
IFS=$'\n'
for match in $matches; do
res="$(objdump -p ${match} | grep LOAD | awk '{ print $NF }' | head -1)"
@@ -78,7 +78,7 @@ for match in $matches; do
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
else
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
- unaligned_libs+=(${match})
+ unaligned_libs+=("${match}")
fi
done