From bd15c23395b92446af40f7df76edefce51b4e999 Mon Sep 17 00:00:00 2001
From: Patrick McDermott <patrick.mcdermott@libiquity.com>
Date: Thu, 25 Apr 2019 18:39:47 -0400
Subject: src/install.sh: Delimit command operands

---
diff --git a/src/install.sh b/src/install.sh
index bfd937c..f1340d9 100644
--- a/src/install.sh
+++ b/src/install.sh
@@ -113,7 +113,7 @@ install_find_pkgs()
 	local dl_func=
 	local pkgs=
 
-	mkdir -p "${root}/etc/opkg" "${root}/$(profile_opkg_state_dir)/lists"
+	mkdir -p -- "${root}/etc/opkg" "${root}/$(profile_opkg_state_dir)/lists"
 	if ! fopen "${root}/$(profile_opkg_conf_file)" 'w'; then
 		return 1
 	fi
@@ -133,7 +133,7 @@ install_find_pkgs()
 		# This is a hack to generate a fake certificate with some valid
 		# (but incorrect) key and the mirror-specific certificate URL to
 		# make opkg-cert download and verify the actual certificate.
-		mkdir -p "${root}/etc/opkg/keys/" "${root}/var/cache/opkg/"
+		mkdir -p -- "${root}/etc/opkg/keys/" "${root}/var/cache/opkg/"
 		root_key="$(profile_get_root_key)"
 		printf '%s\n' "${root_key}" \
 			>"${root}/etc/opkg/keys/$(_usign_fingerprint \
@@ -183,7 +183,7 @@ install_find_pkgs()
 	fclose ${opkg_conf_fd}
 	fclose ${pkgs_fd}
 
-	pkgs="$(resolve_deps "$(cat "${root}/.prokit/packages")" \
+	pkgs="$(resolve_deps "$(cat -- "${root}/.prokit/packages")" \
 		"${install_deps}" | xargs printf '%s\n' | sort -u)"
 	printf '%s\n' "${pkgs}" >"${root}/.prokit/packages"
 
@@ -206,7 +206,7 @@ install_get_pkgs()
 	local field=
 	local printed=
 
-	mkdir -p "${root}/var/cache/opkg/archives" "${root}/tmp/opkg" \
+	mkdir -p -- "${root}/var/cache/opkg/archives" "${root}/tmp/opkg" \
 		"${root}/$(profile_opkg_state_dir)/info"
 
 	if ! fopen "${root}/$(profile_opkg_state_dir)/status" 'w'; then
@@ -216,7 +216,7 @@ install_get_pkgs()
 
 	errors=false
 
-	for pkg in $(cat "${root}/.prokit/packages"); do
+	for pkg in $(cat -- "${root}/.prokit/packages"); do
 		info "$(get_msg 'install_downloading_pkg')" "${pkg}"
 		url="$(printf '%s\n' "${install_urls}" | \
 			sed -n "s/^${pkg} //p")"
@@ -225,7 +225,7 @@ install_get_pkgs()
 		sha256sum="$(printf '%s\n' "${install_sha256sums}" | \
 			sed -n "s/^${pkg} //p")"
 		fname="var/cache/opkg/archives/${url##*/}"
-		if ! ${WGET} -q -O "${root}/${fname}" "${url}"; then
+		if ! ${WGET} -q -O "${root}/${fname}" -- "${url}"; then
 			error "$(get_msg 'install_downloading_pkg_fail')"
 			errors=true
 			continue
@@ -250,36 +250,36 @@ install_get_pkgs()
 		fi
 
 		info "$(get_msg 'install_unpacking_pkg')" "${pkg}"
-		mkdir "${root}/tmp/opkg/${pkg}"
+		mkdir -- "${root}/tmp/opkg/${pkg}"
 		(
-			cd "${root}"
+			cd -- "${root}"
 			tar -xzOf "${fname}" data.tar.gz \
 				>"tmp/opkg/${pkg}/data.tar.gz"
 			tar -xzf "tmp/opkg/${pkg}/data.tar.gz"
-			cd "tmp/opkg/${pkg}"
+			cd -- "tmp/opkg/${pkg}"
 			tar -xzOf "../../../${fname}" control.tar.gz | \
 				tar -xz
 		)
 		tar -tzf "${root}/tmp/opkg/${pkg}/data.tar.gz" | \
 			sed 's/^\.//' \
 			>"${root}/$(profile_opkg_state_dir)/info/${pkg}.list"
-		rm -f "${root}/tmp/opkg/${pkg}/data.tar.gz"
+		rm -f -- "${root}/tmp/opkg/${pkg}/data.tar.gz"
 		for file in "${root}/tmp/opkg/${pkg}/"*; do
-			mv "${file}" \
+			mv -- "${file}" \
 				"${root}/$(profile_opkg_state_dir \
 					)/info/${pkg}.${file##*/}"
 		done
-		rmdir "${root}/tmp/opkg/${pkg}"
+		rmdir -- "${root}/tmp/opkg/${pkg}"
 
 		# Write status file.
 		control="${root}/$(profile_opkg_state_dir)/info/${pkg}.control"
 		for field in Package Version Depends Recommends Suggests \
 				Provides Replaces Conflicts; do
-			grep "^${field}: " "${control}" >&${status_fd}
+			grep -- "^${field}: " "${control}" >&${status_fd}
 		done
 		printf 'Status: install ok unpacked\n' >&${status_fd}
 		for field in Essential Architecture; do
-			grep "^${field}: " "${control}" >&${status_fd}
+			grep -- "^${field}: " "${control}" >&${status_fd}
 		done
 		if [ -r "${root}/$(profile_opkg_state_dir \
 				)/info/${pkg}.conffiles" ]; then
@@ -296,11 +296,11 @@ install_get_pkgs()
 		fi
 		printf 'Installed-Time: %s\n\n' "$(date '+%s')" >&${status_fd}
 
-		rm -f "${root}/${fname}"
+		rm -f -- "${root}/${fname}"
 	done
 
-	rm -f "${root}/.prokit/packages"
-	rmdir "${root}/.prokit"
+	rm -f -- "${root}/.prokit/packages"
+	rmdir -- "${root}/.prokit"
 
 	fclose ${status_fd}
 
@@ -346,7 +346,7 @@ install_system()
 		error "$(get_msg 'install_chroot_dir_exists')" "${root}"
 		return 1
 	fi
-	if ! mkdir -p "${root}/.prokit" "${root}/prokit"; then
+	if ! mkdir -p -- "${root}/.prokit" "${root}/prokit"; then
 		error "$(get_msg 'install_mkdir_chroot_fail')" "${root}"
 		return 1
 	fi
@@ -368,7 +368,7 @@ install_system()
 		profile_configure_system_foreign "${root}" "${arch}" "${plat}"
 	fi
 
-	rm -f "${root}/prokit/installing"
+	rm -f -- "${root}/prokit/installing"
 
 	return 0
 }
--
cgit v0.9.1