extract_utils: template: use quotation marks and variable curly braces consistently
* This makes sure that multi-word arguments are passed correctly from
extract-files.sh towards the common extract_utils helper. An example
would be extract-files --section "Hello World".
* IMPORTANT: device repositories that use a device/common split
typically do something like this to invoke the common script from the
device one:
${MY_DIR}/../common/extract-files.sh $@
This is incorrect because the quotation marks are missing, and will
lead to incorrect parameter parsing. The correct way is:
${MY_DIR}/../common/extract-files.sh "$@"
* The curly braces are only for cosmetic consistency.
Change-Id: Idf0885546379f47e675ec5e9dfb304706e512129
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
diff --git a/build/templates/extract-files.sh b/build/templates/extract-files.sh
index fd6e7eb..c6f3926 100755
--- a/build/templates/extract-files.sh
+++ b/build/templates/extract-files.sh
@@ -23,41 +23,41 @@
# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
-if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
+if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi
-LINEAGE_ROOT="$MY_DIR"/../../..
+LINEAGE_ROOT="${MY_DIR}/../../.."
-HELPER="$LINEAGE_ROOT"/vendor/lineage/build/tools/extract_utils.sh
-if [ ! -f "$HELPER" ]; then
- echo "Unable to find helper script at $HELPER"
+HELPER="${LINEAGE_ROOT}/vendor/lineage/build/tools/extract_utils.sh"
+if [ ! -f "${HELPER}" ]; then
+ echo "Unable to find helper script at ${HELPER}"
exit 1
fi
-. "$HELPER"
+source "${HELPER}"
# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true
while [ "$1" != "" ]; do
- case $1 in
+ case "$1" in
-n | --no-cleanup ) CLEAN_VENDOR=false
;;
-s | --section ) shift
- SECTION=$1
+ SECTION="$1"
CLEAN_VENDOR=false
;;
- * ) SRC=$1
+ * ) SRC="$1"
;;
esac
shift
done
-if [ -z "$SRC" ]; then
+if [ -z "${SRC}" ]; then
SRC=adb
fi
# Initialize the helper
-setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" false "$CLEAN_VENDOR"
+setup_vendor "${DEVICE}" "${VENDOR}" "${LINEAGE_ROOT}" false "${CLEAN_VENDOR}"
-extract "$MY_DIR"/proprietary-files.txt "$SRC" "$SECTION"
+extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${SECTION}"
-"$MY_DIR"/setup-makefiles.sh
+"${MY_DIR}/setup-makefiles.sh"