public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: bin/ebuild-helpers/xattr/, bin/ebuild-helpers/, bin/postinst-qa-check.d/, bin/, ...
@ 2022-08-01 22:39 Sam James
  0 siblings, 0 replies; only message in thread
From: Sam James @ 2022-08-01 22:39 UTC (permalink / raw
  To: gentoo-commits

commit:     cb8eda531dad92bec9293c89f93db9b581245fd3
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 28 01:25:22 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Aug  1 22:38:11 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cb8eda53

bin: style tweaks

Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/bashrc-functions.sh                         |  18 +-
 bin/binhost-snapshot                            |   2 +-
 bin/chpathtool.py                               |   8 +-
 bin/doins.py                                    |   8 +-
 bin/ebuild                                      |   2 +-
 bin/ebuild-helpers/bsd/sed                      |   3 +-
 bin/ebuild-helpers/dobin                        |   6 +-
 bin/ebuild-helpers/dodir                        |   4 +-
 bin/ebuild-helpers/dodoc                        |   4 +-
 bin/ebuild-helpers/doexe                        |  17 +-
 bin/ebuild-helpers/dohard                       |   4 +-
 bin/ebuild-helpers/dohtml                       |  10 +-
 bin/ebuild-helpers/doinfo                       |   6 +-
 bin/ebuild-helpers/doins                        |   4 +-
 bin/ebuild-helpers/dolib                        |  10 +-
 bin/ebuild-helpers/doman                        |  10 +-
 bin/ebuild-helpers/domo                         |   8 +-
 bin/ebuild-helpers/dosbin                       |   4 +-
 bin/ebuild-helpers/dosed                        |   8 +-
 bin/ebuild-helpers/dosym                        |  14 +-
 bin/ebuild-helpers/fowners                      |   6 +-
 bin/ebuild-helpers/fperms                       |   6 +-
 bin/ebuild-helpers/newins                       |  14 +-
 bin/ebuild-helpers/portageq                     |   1 +
 bin/ebuild-helpers/prepallstrip                 |   2 +-
 bin/ebuild-helpers/prepinfo                     |   3 +-
 bin/ebuild-helpers/prepstrip                    |   2 +-
 bin/ebuild-helpers/unprivileged/chown           |   3 +-
 bin/ebuild-helpers/xattr/install                |   2 +-
 bin/ebuild.sh                                   | 178 ++++++++--------
 bin/ecompress                                   |  13 +-
 bin/ecompress-file                              |  15 +-
 bin/egencache                                   |   8 +-
 bin/emerge-webrsync                             |  31 ++-
 bin/estrip                                      |  41 ++--
 bin/etc-update                                  |  27 ++-
 bin/install-qa-check.d/05prefix                 |   8 +-
 bin/install-qa-check.d/10executable-issues      |   2 +-
 bin/install-qa-check.d/20deprecated-directories |   6 +-
 bin/install-qa-check.d/60udev                   |   5 +-
 bin/install-qa-check.d/80libraries              |   2 +-
 bin/install-qa-check.d/90bad-bin-owner          |   2 +-
 bin/install-qa-check.d/90gcc-warnings           |  10 +-
 bin/install-qa-check.d/90world-writable         |  10 +-
 bin/isolated-functions.sh                       |  51 ++---
 bin/misc-functions.sh                           |  99 +++++----
 bin/phase-functions.sh                          | 267 +++++++++++++-----------
 bin/phase-helpers.sh                            | 160 ++++++++------
 bin/portageq                                    |   4 +-
 bin/postinst-qa-check.d/50xdg-utils             |  21 +-
 bin/save-ebuild-env.sh                          |   8 +-
 51 files changed, 635 insertions(+), 522 deletions(-)

diff --git a/bin/bashrc-functions.sh b/bin/bashrc-functions.sh
index a45587b28..7d6aab544 100644
--- a/bin/bashrc-functions.sh
+++ b/bin/bashrc-functions.sh
@@ -5,22 +5,22 @@
 register_die_hook() {
 	local x
 	for x in $* ; do
-		has $x $EBUILD_DEATH_HOOKS || \
-			export EBUILD_DEATH_HOOKS="$EBUILD_DEATH_HOOKS $x"
+		has ${x} ${EBUILD_DEATH_HOOKS} || \
+			export EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} ${x}"
 	done
 }
 
 register_success_hook() {
 	local x
 	for x in $* ; do
-		has $x $EBUILD_SUCCESS_HOOKS || \
-			export EBUILD_SUCCESS_HOOKS="$EBUILD_SUCCESS_HOOKS $x"
+		has ${x} ${EBUILD_SUCCESS_HOOKS} || \
+			export EBUILD_SUCCESS_HOOKS="${EBUILD_SUCCESS_HOOKS} ${x}"
 	done
 }
 
 __strip_duplicate_slashes() {
-	if [[ -n $1 ]] ; then
-		local removed=$1
+	if [[ -n ${1} ]] ; then
+		local removed=${1}
 		while [[ ${removed} == *//* ]] ; do
 			removed=${removed//\/\///}
 		done
@@ -29,14 +29,14 @@ __strip_duplicate_slashes() {
 }
 
 KV_major() {
-	[[ -z $1 ]] && return 1
+	[[ -z ${1} ]] && return 1
 
 	local KV=$@
 	echo "${KV%%.*}"
 }
 
 KV_minor() {
-	[[ -z $1 ]] && return 1
+	[[ -z ${1} ]] && return 1
 
 	local KV=$@
 	KV=${KV#*.}
@@ -44,7 +44,7 @@ KV_minor() {
 }
 
 KV_micro() {
-	[[ -z $1 ]] && return 1
+	[[ -z ${1} ]] && return 1
 
 	local KV=$@
 	KV=${KV#*.*.}

diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot
index 4022cb32c..2076f2e53 100755
--- a/bin/binhost-snapshot
+++ b/bin/binhost-snapshot
@@ -44,7 +44,7 @@ def parse_args(argv):
 
     usage += "\n"
     usage += "Required Arguments:\n\n"
-    usage += "  src_pkg_dir  - the source $PKGDIR\n"
+    usage += "  src_pkg_dir  - the source ${PKGDIR}\n"
     usage += "  snapshot_dir - destination snapshot " + "directory (must not exist)\n"
     usage += (
         "  snapshot_uri - URI which refers to "

diff --git a/bin/chpathtool.py b/bin/chpathtool.py
index d658e5012..de47b097f 100755
--- a/bin/chpathtool.py
+++ b/bin/chpathtool.py
@@ -4,7 +4,7 @@
 
 doc = """Helper tool for converting installed files to custom prefixes.
 
-In other words, eprefixy $D for Gentoo/Prefix."""
+In other words, eprefixy ${D} for Gentoo/Prefix."""
 __doc__ = doc
 
 import argparse
@@ -146,9 +146,11 @@ def chpath_inplace_symlink(filename, st, old, new):
 def main(argv):
 
     parser = argparse.ArgumentParser(description=doc)
-    parser.add_argument("location", default=None, help="root directory (e.g. $D)")
+    parser.add_argument("location", default=None, help="root directory (e.g. ${D})")
     parser.add_argument("old", default=None, help="original build prefix (e.g. /)")
-    parser.add_argument("new", default=None, help="new install prefix (e.g. $EPREFIX)")
+    parser.add_argument(
+        "new", default=None, help="new install prefix (e.g. ${EPREFIX})"
+    )
     opts = parser.parse_args(argv)
 
     location, old, new = opts.location, opts.old, opts.new

diff --git a/bin/doins.py b/bin/doins.py
index 7905c5c0d..77f9fe021 100644
--- a/bin/doins.py
+++ b/bin/doins.py
@@ -412,11 +412,11 @@ def _doins(opts, install_runner, relpath, source_root):
     source = os.path.join(source_root, relpath)
     dest = os.path.join(opts.dest, relpath)
     if os.path.islink(source):
-        # Our fake $DISTDIR contains symlinks that should not be
-        # reproduced inside $D. In order to ensure that things like
-        # dodoc "$DISTDIR"/foo.pdf work as expected, we dereference
+        # Our fake ${DISTDIR} contains symlinks that should not be
+        # reproduced inside ${D}. In order to ensure that things like
+        # dodoc "${DISTDIR}"/foo.pdf work as expected, we dereference
         # symlinked files that refer to absolute paths inside
-        # $PORTAGE_ACTUAL_DISTDIR/.
+        # ${PORTAGE_ACTUAL_DISTDIR}/.
         try:
             if opts.preserve_symlinks and not os.readlink(source).startswith(
                 opts.distdir

diff --git a/bin/ebuild b/bin/ebuild
index 546ab9d1c..ff2b4fe92 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -278,7 +278,7 @@ build_dir_phases = set(
 )
 
 # If the current metadata is invalid then force the ebuild to be
-# sourced again even if $T/environment already exists.
+# sourced again even if ${T}/environment already exists.
 ebuild_changed = False
 if mytree == "porttree" and build_dir_phases.intersection(pargs):
     ebuild_changed = (

diff --git a/bin/ebuild-helpers/bsd/sed b/bin/ebuild-helpers/bsd/sed
index 2d7b844da..f19460b90 100755
--- a/bin/ebuild-helpers/bsd/sed
+++ b/bin/ebuild-helpers/bsd/sed
@@ -13,10 +13,11 @@ else
 	old_IFS="${IFS}"
 	IFS=":"
 
-	for path in $PATH; do
+	for path in ${PATH}; do
 		if [[ -x ${path}/${scriptname} ]]; then
 			[[ ${path} == */portage/*/ebuild-helpers* ]] && continue
 			[[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
+
 			exec "${path}/${scriptname}" "$@"
 			exit 0
 		fi

diff --git a/bin/ebuild-helpers/dobin b/bin/ebuild-helpers/dobin
index 8abcc713c..14faab9bf 100755
--- a/bin/ebuild-helpers/dobin
+++ b/bin/ebuild-helpers/dobin
@@ -15,7 +15,7 @@ fi
 
 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
 	[[ -n ${DESTTREE} ]] &&
-		die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
+		die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
 else
 	# backwards compatibility
 	_E_DESTTREE_=${DESTTREE}
@@ -31,11 +31,11 @@ for x in "$@" ; do
 	if [[ -e ${x} ]] ; then
 		install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED%/}/${_E_DESTTREE_#/}/bin"
 	else
-		echo "!!! ${0##*/}: $x does not exist" 1>&2
+		echo "!!! ${0##*/}: ${x} does not exist" 1>&2
 		false
 	fi
 	((ret|=$?))
 done
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit ${ret}

diff --git a/bin/ebuild-helpers/dodir b/bin/ebuild-helpers/dodir
index 4fb113819..727f62a99 100755
--- a/bin/ebuild-helpers/dodir
+++ b/bin/ebuild-helpers/dodir
@@ -10,5 +10,5 @@ fi
 
 install -d ${DIROPTIONS} "${@/#/${ED%/}/}"
 ret=$?
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/dodoc b/bin/ebuild-helpers/dodoc
index af3764b7e..28e58ae0c 100755
--- a/bin/ebuild-helpers/dodoc
+++ b/bin/ebuild-helpers/dodoc
@@ -29,10 +29,10 @@ for x in "$@" ; do
 	elif [ -s "${x}" ] ; then
 		install -m0644 "${x}" "${dir}" || { ((ret|=1)); continue; }
 	elif [ ! -e "${x}" ] ; then
-		echo "!!! ${0##*/}: $x does not exist" 1>&2
+		echo "!!! ${0##*/}: ${x} does not exist" 1>&2
 		((ret|=1))
 	fi
 done
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit ${ret}

diff --git a/bin/ebuild-helpers/doexe b/bin/ebuild-helpers/doexe
index 154f5daca..9132fb592 100755
--- a/bin/ebuild-helpers/doexe
+++ b/bin/ebuild-helpers/doexe
@@ -23,24 +23,25 @@ ret=0
 
 for x in "$@" ; do
 	if [ -L "${x}" ] ; then
-		cp "$x" "$TMP"
-		mysrc=$TMP/${x##*/}
+		cp "${x}" "${TMP}"
+		mysrc=${TMP}/${x##*/}
 	elif [ -d "${x}" ] ; then
 		__vecho "doexe: warning, skipping directory ${x}"
 		continue
 	else
 		mysrc="${x}"
 	fi
-	if [ -e "$mysrc" ] ; then
-		install ${EXEOPTIONS} "$mysrc" "${ED%/}/${_E_EXEDESTTREE_#/}"
+
+	if [ -e "${mysrc}" ] ; then
+		install ${EXEOPTIONS} "${mysrc}" "${ED%/}/${_E_EXEDESTTREE_#/}"
 	else
-		echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
+		echo "!!! ${0##*/}: ${mysrc} does not exist" 1>&2
 		false
 	fi
 	((ret|=$?))
 done
 
-rm -rf "$TMP"
+rm -rf "${TMP}"
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/dohard b/bin/ebuild-helpers/dohard
index 4ee1ba258..326752b4f 100755
--- a/bin/ebuild-helpers/dohard
+++ b/bin/ebuild-helpers/dohard
@@ -5,12 +5,12 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_dohard; then
-	die "'${0##*/}' has been banned for EAPI '$EAPI'"
+	die "'${0##*/}' has been banned for EAPI '${EAPI}'"
 	exit 1
 fi
 
 if [[ $# -ne 2 ]] ; then
-	echo "$0: two arguments needed" 1>&2
+	echo "${0}: two arguments needed" 1>&2
 	exit 1
 fi
 

diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml
index b6373a36c..55339238e 100755
--- a/bin/ebuild-helpers/dohtml
+++ b/bin/ebuild-helpers/dohtml
@@ -5,22 +5,22 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_dohtml; then
-	die "'${0##*/}' has been banned for EAPI '$EAPI'"
+	die "'${0##*/}' has been banned for EAPI '${EAPI}'"
 	exit 1
 fi
 
 if ___eapi_has_dohtml_deprecated; then
-	eqawarn "'${0##*/}' is deprecated in EAPI '$EAPI'"
+	eqawarn "'${0##*/}' is deprecated in EAPI '${EAPI}'"
 fi
 
 # Use safe cwd, avoiding unsafe import for bug #469338.
 export __PORTAGE_HELPER_CWD=${PWD}
 cd "${PORTAGE_PYM_PATH}" || die
 PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-	"${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/dohtml.py" "$@"
+	"${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/dohtml.py" "$@"
 
 ret=$?
 # Restore cwd for display by __helpers_die
 cd "${__PORTAGE_HELPER_CWD}"
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/doinfo b/bin/ebuild-helpers/doinfo
index cf4d42b1a..69de67026 100755
--- a/bin/ebuild-helpers/doinfo
+++ b/bin/ebuild-helpers/doinfo
@@ -19,10 +19,10 @@ fi
 
 install -m0644 "$@" "${ED%/}/usr/share/info"
 rval=$?
-if [ $rval -ne 0 ] ; then
+if [ ${rval} -ne 0 ] ; then
 	for x in "$@" ; do
-		[ -e "$x" ] || echo "!!! ${0##*/}: $x does not exist" 1>&2
+		[ -e "${x}" ] || echo "!!! ${0##*/}: ${x} does not exist" 1>&2
 	done
 	__helpers_die "${0##*/} failed"
 fi
-exit $rval
+exit ${rval}

diff --git a/bin/ebuild-helpers/doins b/bin/ebuild-helpers/doins
index a5fc224a9..c90eccc90 100755
--- a/bin/ebuild-helpers/doins
+++ b/bin/ebuild-helpers/doins
@@ -20,7 +20,7 @@ if [[ ${helper} == dodoc ]] ; then
 else
 	if ! ___eapi_has_DESTTREE_INSDESTTREE; then
 		[[ -n ${INSDESTTREE} ]] &&
-			die "${0##*/}: \${INSDESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
+			die "${0##*/}: \${INSDESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
 	else
 		# backwards compatibility
 		_E_INSDESTTREE_=${INSDESTTREE}
@@ -33,7 +33,7 @@ if [ $# -lt 1 ] ; then
 fi
 
 DOINS_ARGS=()
-if [[ "$1" == "-r" ]] ; then
+if [[ "${1}" == "-r" ]] ; then
 	DOINS_ARGS+=( --recursive )
 	shift
 fi

diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
index c31442a8e..ca57199be 100755
--- a/bin/ebuild-helpers/dolib
+++ b/bin/ebuild-helpers/dolib
@@ -5,7 +5,7 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [[ -z ${PORTAGE_INTERNAL_DOLIB} ]] && ! ___eapi_has_dolib_libopts; then
-	die "'${0##*/}' has been banned for EAPI '$EAPI'"
+	die "'${0##*/}' has been banned for EAPI '${EAPI}'"
 	exit 1
 fi
 
@@ -15,7 +15,7 @@ fi
 
 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
 	[[ -n ${DESTTREE} ]] &&
-		die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
+		die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
 else
 	# backwards compatibility
 	_E_DESTTREE_=${DESTTREE}
@@ -27,11 +27,11 @@ if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
 	CONF_LIBDIR=${!LIBDIR_VAR}
 fi
 unset LIBDIR_VAR
-# we need this to default to lib so that things dont break
+
+# We need this to default to lib so that things dont break
 CONF_LIBDIR=${CONF_LIBDIR:-lib}
 libdir="${ED%/}/${_E_DESTTREE_#/}/${CONF_LIBDIR}"
 
-
 if [[ $# -lt 1 ]] ; then
 	__helpers_die "${0##*/}: at least one argument needed"
 	exit 1
@@ -56,5 +56,5 @@ for x in "$@" ; do
 	((ret|=$?))
 done
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit ${ret}

diff --git a/bin/ebuild-helpers/doman b/bin/ebuild-helpers/doman
index c2418ce40..67945f48b 100755
--- a/bin/ebuild-helpers/doman
+++ b/bin/ebuild-helpers/doman
@@ -22,6 +22,7 @@ for x in "$@" ; do
 		i18n=${x:6}/
 		continue
 	fi
+
 	if [[ ${x:0:6} == ".keep_" ]] ; then
 		continue
 	fi
@@ -35,9 +36,8 @@ for x in "$@" ; do
 		suffix=${realname##*.}
 	fi
 
-	if has "${EAPI:-0}" 2 3 || [[ -z ${i18n} ]] \
-		&& ! has "${EAPI:-0}" 0 1 \
-		&& [[ $x =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
+	if has "${EAPI:-0}" 2 3 || [[ -z ${i18n} ]] && ! has "${EAPI:-0}" 0 1 \
+		&& [[ ${x} =~ (.*)\.([a-z][a-z](_[A-Z][A-Z])?)\.(.*) ]]
 	then
 		name=${BASH_REMATCH[1]##*/}.${BASH_REMATCH[4]}
 		mandir=${BASH_REMATCH[2]}/man${suffix:0:1}
@@ -56,7 +56,7 @@ for x in "$@" ; do
 			install -m0644 "${x}" "${ED%/}/usr/share/man/${mandir}/${name}"
 			((ret|=$?))
 		elif [[ ! -e ${x} ]] ; then
-			echo "!!! ${0##*/}: $x does not exist" 1>&2
+			echo "!!! ${0##*/}: ${x} does not exist" 1>&2
 			((ret|=1))
 		fi
 	else
@@ -65,5 +65,5 @@ for x in "$@" ; do
 	fi
 done
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit ${ret}

diff --git a/bin/ebuild-helpers/domo b/bin/ebuild-helpers/domo
index 474bb7e1d..d864bed29 100755
--- a/bin/ebuild-helpers/domo
+++ b/bin/ebuild-helpers/domo
@@ -16,7 +16,7 @@ fi
 
 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
 	[[ -n ${DESTTREE} ]] &&
-		die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
+		die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
 else
 	# backwards compatibility
 	_E_DESTTREE_=${DESTTREE}
@@ -42,11 +42,11 @@ for x in "$@" ; do
 		fi
 		install -m0644 "${x}" "${mydir}/${MOPREFIX}.mo"
 	else
-		echo "!!! ${0##*/}: $x does not exist" 1>&2
+		echo "!!! ${0##*/}: ${x} does not exist" 1>&2
 		false
 	fi
 	((ret|=$?))
 done
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/dosbin b/bin/ebuild-helpers/dosbin
index 1ff253bb1..4d2c8540b 100755
--- a/bin/ebuild-helpers/dosbin
+++ b/bin/ebuild-helpers/dosbin
@@ -15,7 +15,7 @@ fi
 
 if ! ___eapi_has_DESTTREE_INSDESTTREE; then
 	[[ -n ${DESTTREE} ]] &&
-		die "${0##*/}: \${DESTTREE} has been banned for EAPI '$EAPI'; use 'into' instead"
+		die "${0##*/}: \${DESTTREE} has been banned for EAPI '${EAPI}'; use 'into' instead"
 else
 	# backwards compatibility
 	_E_DESTTREE_=${DESTTREE}
@@ -37,5 +37,5 @@ for x in "$@" ; do
 	((ret|=$?))
 done
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit ${ret}

diff --git a/bin/ebuild-helpers/dosed b/bin/ebuild-helpers/dosed
index d3c249352..748ab414a 100755
--- a/bin/ebuild-helpers/dosed
+++ b/bin/ebuild-helpers/dosed
@@ -5,7 +5,7 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ! ___eapi_has_dosed; then
-	die "'${0##*/}' has been banned for EAPI '$EAPI'"
+	die "'${0##*/}' has been banned for EAPI '${EAPI}'"
 	exit 1
 fi
 
@@ -38,9 +38,9 @@ for x in "$@" ; do
 	fi
 done
 
-if [ $file_found = 0 ] ; then
-	echo "!!! ${0##*/}: $y does not exist" 1>&2
+if [ ${file_found} = 0 ] ; then
+	echo "!!! ${0##*/}: ${y} does not exist" 1>&2
 	((ret|=1))
 fi
 
-exit $ret
+exit ${ret}

diff --git a/bin/ebuild-helpers/dosym b/bin/ebuild-helpers/dosym
index 69a4a1ebe..e41558a15 100755
--- a/bin/ebuild-helpers/dosym
+++ b/bin/ebuild-helpers/dosym
@@ -5,7 +5,7 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 option_r=
-if ___eapi_has_dosym_r && [[ $1 == -r ]]; then
+if ___eapi_has_dosym_r && [[ ${1} == -r ]]; then
 	option_r=t
 	shift
 fi
@@ -24,7 +24,7 @@ if [[ ${2} == */ ]] || [[ -d ${ED%/}/${2#/} && ! -L ${ED%/}/${2#/} ]] ; then
 	__helpers_die "${0##*/}: dosym target omits basename: '${2}'"
 fi
 
-target=$1
+target=${1}
 
 if [[ ${option_r} ]]; then
 	# Transparent bash-only replacement for GNU "realpath -m -s".
@@ -33,8 +33,8 @@ if [[ ${option_r} ]]; then
 	dosym_canonicalize() {
 		local path slash i prev out IFS=/
 
-		path=( $1 )
-		[[ $1 == /* ]] && slash=/
+		path=( ${1} )
+		[[ ${1} == /* ]] && slash=/
 
 		while true; do
 			# Find first instance of non-".." path component followed by "..",
@@ -87,6 +87,6 @@ destdir=${2%/*}
 [[ ! -d ${ED%/}/${destdir#/} ]] && dodir "${destdir}"
 ln -snf "${target}" "${ED%/}/${2#/}"
 
-ret=$?
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+ret=${?}
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
index c6ed36ed3..d245062e7 100755
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@ -11,10 +11,12 @@ fi
 got_owner=
 for arg; do
 	[[ ${arg} == -* ]] && continue
+
 	if [[ ! ${got_owner} ]]; then
 		got_owner=1
 		continue
 	fi
+
 	if [[ ${arg} != /* ]]; then
 		eqawarn "Relative path passed to '${0##*/}': ${arg}"
 		eqawarn "This is unsupported. Please use 'chown' when you need to work on files"
@@ -29,5 +31,5 @@ slash="/"
 chown "${@/#${slash}/${ED%/}${slash}}"
 ret=$?
 
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/fperms b/bin/ebuild-helpers/fperms
index 9620cc06a..9e5da5d16 100755
--- a/bin/ebuild-helpers/fperms
+++ b/bin/ebuild-helpers/fperms
@@ -12,10 +12,12 @@ got_mode=
 for arg; do
 	# - can either be an option or a mode string
 	[[ ${arg} == -* && ${arg} != -[ugorwxXst] ]] && continue
+
 	if [[ ! ${got_mode} ]]; then
 		got_mode=1
 		continue
 	fi
+
 	if [[ ${arg} != /* ]]; then
 		eqawarn "Relative path passed to '${0##*/}': ${arg}"
 		eqawarn "This is unsupported. Please use 'chmod' when you need to work on files"
@@ -28,5 +30,5 @@ done
 slash="/"
 chmod "${@/#${slash}/${ED%/}${slash}}"
 ret=$?
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/newins b/bin/ebuild-helpers/newins
index d05d688ac..02186a6b3 100755
--- a/bin/ebuild-helpers/newins
+++ b/bin/ebuild-helpers/newins
@@ -15,7 +15,7 @@ fi
 	eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${*:3}"
 
 stdin=
-if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then
+if ___eapi_newins_supports_reading_from_standard_input && [[ ${1} == "-" ]]; then
 	stdin=yes
 fi
 
@@ -27,11 +27,11 @@ if [[ ${stdin} ]] ; then
 		__helpers_die "!!! ${helper}: Input is from a terminal"
 		exit 1
 	fi
-	cat > "${TMP}/$2"
+	cat > "${TMP}/${2}"
 	ret=$?
 else
 	if [[ ! -e $1 ]] ; then
-		__helpers_die "!!! ${helper}: $1 does not exist"
+		__helpers_die "!!! ${helper}: ${1} does not exist"
 		exit 1
 	fi
 
@@ -42,7 +42,7 @@ else
 		fi
 	fi
 
-	cp ${cp_args} "$1" "${TMP}/$2"
+	cp ${cp_args} "${1}" "${TMP}/$2"
 	ret=$?
 fi
 
@@ -51,7 +51,7 @@ if [[ ${ret} -ne 0 ]] ; then
 	exit ${ret}
 fi
 
-do${helper#new} "${TMP}/$2"
+do${helper#new} "${TMP}/${2}"
 ret=$?
-[[ $ret -ne 0 ]] && __helpers_die "${helper} failed"
-exit $ret
+[[ ${ret} -ne 0 ]] && __helpers_die "${helper} failed"
+exit ${ret}

diff --git a/bin/ebuild-helpers/portageq b/bin/ebuild-helpers/portageq
index 199804f7b..7d14f54c2 100755
--- a/bin/ebuild-helpers/portageq
+++ b/bin/ebuild-helpers/portageq
@@ -15,6 +15,7 @@ for path in ${PATH}; do
 	[[ -x ${path}/${scriptname} ]] || continue
 	[[ ${path} == */portage/*/ebuild-helpers* ]] && continue
 	[[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
+
 	PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
 		exec "${PORTAGE_PYTHON:-/usr/bin/python}" \
 			"${path}/${scriptname}" "$@"

diff --git a/bin/ebuild-helpers/prepallstrip b/bin/ebuild-helpers/prepallstrip
index 2bf567634..2f9c0f70e 100755
--- a/bin/ebuild-helpers/prepallstrip
+++ b/bin/ebuild-helpers/prepallstrip
@@ -5,7 +5,7 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ___eapi_has_dostrip; then
-	die "${0##*/}: ${0##*/} has been banned for EAPI '$EAPI'; use 'dostrip' instead"
+	die "${0##*/}: ${0##*/} has been banned for EAPI '${EAPI}'; use 'dostrip' instead"
 fi
 
 if ! ___eapi_has_prefix_variables; then

diff --git a/bin/ebuild-helpers/prepinfo b/bin/ebuild-helpers/prepinfo
index e771c97aa..9e509e8ca 100755
--- a/bin/ebuild-helpers/prepinfo
+++ b/bin/ebuild-helpers/prepinfo
@@ -8,7 +8,7 @@ if ! ___eapi_has_prefix_variables; then
 	ED=${D}
 fi
 
-if [[ -z $1 ]] ; then
+if [[ -z ${1} ]] ; then
 	infodir="/usr/share/info"
 else
 	if [[ -d ${ED%/}/${1#/}/share/info ]] ; then
@@ -31,6 +31,7 @@ find "${ED%/}/${infodir#/}" -type d -print0 | while read -r -d $'\0' x ; do
 	for f in "${x}"/.keepinfodir*; do
 		[[ -e ${f} ]] && continue 2
 	done
+
 	rm -f "${x}"/dir{,.info}{,.gz,.bz2}
 done
 

diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index 9b523517c..789296050 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -5,7 +5,7 @@
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if ___eapi_has_dostrip; then
-	die "${0##*/}: ${0##*/} has been banned for EAPI '$EAPI'; use 'dostrip' instead"
+	die "${0##*/}: ${0##*/} has been banned for EAPI '${EAPI}'; use 'dostrip' instead"
 fi
 
 __PORTAGE_HELPER=prepstrip exec "${PORTAGE_BIN_PATH}"/estrip "${@}"

diff --git a/bin/ebuild-helpers/unprivileged/chown b/bin/ebuild-helpers/unprivileged/chown
index 572664324..0788a8b15 100755
--- a/bin/ebuild-helpers/unprivileged/chown
+++ b/bin/ebuild-helpers/unprivileged/chown
@@ -13,10 +13,10 @@ for path in ${PATH}; do
 	[[ -x ${path}/${scriptname} ]] || continue
 	[[ ${path} == */portage/*/ebuild-helpers* ]] && continue
 	[[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
+
 	IFS=$' \t\n'
 	output=$("${path}/${scriptname}" "$@" 2>&1)
 	if [[ $? -ne 0 ]] ; then
-
 		# Avoid an extreme performance problem when the
 		# output is very long (bug #470992).
 		if [[ $(wc -l <<< "${output}") -gt 100 ]]; then
@@ -27,6 +27,7 @@ for path in ${PATH}; do
 		if ! ___eapi_has_prefix_variables; then
 			EPREFIX=
 		fi
+
 		msg="${scriptname} failure ignored with unprivileged user:\n    ${scriptname} $*\n    ${output}"
 		# Reverse expansion of ${D} and ${EPREFIX}, for readability.
 		msg=${msg//${D}/'${D}'}

diff --git a/bin/ebuild-helpers/xattr/install b/bin/ebuild-helpers/xattr/install
index ebc68645e..52ecf5a53 100755
--- a/bin/ebuild-helpers/xattr/install
+++ b/bin/ebuild-helpers/xattr/install
@@ -23,7 +23,7 @@ else
 fi
 
 # Filter internal portage paths from PATH, in order to avoid
-# a possible exec loop or fork bomb (see bug 547086).
+# a possible exec loop or fork bomb (see bug #547086).
 IFS=':'
 set -f
 path=

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 6bb5d45b7..417bca78a 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -53,7 +53,7 @@ __check_bash_version() {
 }
 __check_bash_version
 
-if [[ $EBUILD_PHASE != depend ]] ; then
+if [[ ${EBUILD_PHASE} != depend ]] ; then
 	source "${PORTAGE_BIN_PATH}/phase-functions.sh" || die
 	source "${PORTAGE_BIN_PATH}/save-ebuild-env.sh" || die
 	source "${PORTAGE_BIN_PATH}/phase-helpers.sh" || die
@@ -104,29 +104,29 @@ export PORTAGE_BZIP2_COMMAND=${PORTAGE_BZIP2_COMMAND:-bzip2}
 # when they are done.
 
 __qa_source() {
-	local shopts=$(shopt) OLDIFS="$IFS"
+	local shopts=$(shopt) OLDIFS="${IFS}"
 	local retval
 	source "$@"
 	retval=$?
 	set +e
-	[[ $shopts != $(shopt) ]] &&
+	[[ ${shopts} != $(shopt) ]] &&
 		eqawarn "QA Notice: Global shell options changed and were not restored while sourcing '$*'"
-	[[ "$IFS" != "$OLDIFS" ]] &&
+	[[ "${IFS}" != "${OLDIFS}" ]] &&
 		eqawarn "QA Notice: Global IFS changed and was not restored while sourcing '$*'"
-	return $retval
+	return ${retval}
 }
 
 __qa_call() {
-	local shopts=$(shopt) OLDIFS="$IFS"
+	local shopts=$(shopt) OLDIFS="${IFS}"
 	local retval
 	"$@"
 	retval=$?
 	set +e
-	[[ $shopts != $(shopt) ]] &&
+	[[ ${shopts} != $(shopt) ]] &&
 		eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'"
-	[[ "$IFS" != "$OLDIFS" ]] &&
+	[[ "${IFS}" != "${OLDIFS}" ]] &&
 		eqawarn "QA Notice: Global IFS changed and was not restored while calling '$*'"
-	return $retval
+	return ${retval}
 }
 
 EBUILD_SH_ARGS="$*"
@@ -142,7 +142,7 @@ if ___eapi_has_ENV_UNSET; then
 	unset x
 fi
 
-[[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET
+[[ ${PORTAGE_QUIET} != "" ]] && export PORTAGE_QUIET
 
 # sandbox support functions; defined prior to profile.bashrc srcing, since the profile might need to add a default exception (e.g. /usr/lib64/conftest)
 __sb_append_var() {
@@ -164,11 +164,11 @@ addread "/:${PORTAGE_TMPDIR}/portage"
 [[ -n ${PORTAGE_GPG_DIR} ]] && addpredict "${PORTAGE_GPG_DIR}"
 
 # Avoid sandbox violations in temporary directories.
-if [[ -w $T ]] ; then
-	export TEMP=$T
-	export TMP=$T
-	export TMPDIR=$T
-elif [[ $SANDBOX_ON = 1 ]] ; then
+if [[ -w ${T} ]] ; then
+	export TEMP=${T}
+	export TMP=${T}
+	export TMPDIR=${T}
+elif [[ ${SANDBOX_ON} = 1 ]] ; then
 	for x in TEMP TMP TMPDIR ; do
 		[[ -n ${!x} ]] && addwrite "${!x}"
 	done
@@ -178,7 +178,7 @@ fi
 # The sandbox is disabled by default except when overridden in the relevant stages
 export SANDBOX_ON=0
 
-# Ensure that $PWD is sane whenever possible, to protect against
+# Ensure that ${PWD} is sane whenever possible, to protect against
 # exploitation of insecure search path for python -c in ebuilds.
 # See bug #239560, bug #469338, and bug #595028.
 # EAPI 8 requires us to use an empty directory here.
@@ -196,9 +196,9 @@ umask 022
 # Sources all eclasses in parameters
 declare -ix ECLASS_DEPTH=0
 inherit() {
-	ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
+	ECLASS_DEPTH=$((${ECLASS_DEPTH} + 1))
 	if [[ ${ECLASS_DEPTH} -gt 1 ]]; then
-		debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
+		debug-print "*** Multiple Inheritance (Level: ${ECLASS_DEPTH})"
 
 		# Since ECLASS_DEPTH > 1, the following variables are locals from the
 		# previous inherit call in the call stack.
@@ -224,13 +224,13 @@ inherit() {
 	local B_IDEPEND
 	local B_PROPERTIES
 	local B_RESTRICT
-	while [[ "$1" ]]; do
+	while [[ "${1}" ]]; do
 		location=""
 		potential_location=""
 
-		ECLASS="$1"
-		__export_funcs_var=__export_functions_$ECLASS_DEPTH
-		unset $__export_funcs_var
+		ECLASS="${1}"
+		__export_funcs_var=__export_functions_${ECLASS_DEPTH}
+		unset ${__export_funcs_var}
 
 		if [[ ${EBUILD_PHASE} != depend && ${EBUILD_PHASE} != nofetch && \
 			${EBUILD_PHASE} != *rm && ${EMERGE_FROM} != "binary" && \
@@ -242,8 +242,8 @@ inherit() {
 			# disabled for nofetch, since that can be called by repoman and
 			# that triggers bug #407449 due to repoman not exporting
 			# non-essential variables such as INHERITED.
-			if ! has $ECLASS $INHERITED $__INHERITED_QA_CACHE ; then
-				eqawarn "QA Notice: ECLASS '$ECLASS' inherited illegally in $CATEGORY/$PF $EBUILD_PHASE"
+			if ! has ${ECLASS} ${INHERITED} ${__INHERITED_QA_CACHE} ; then
+				eqawarn "QA Notice: Eclass '${ECLASS}' inherited illegally in ${CATEGORY}/${PF} ${EBUILD_PHASE}"
 			fi
 		fi
 
@@ -255,7 +255,7 @@ inherit() {
 				break
 			fi
 		done
-		debug-print "inherit: $1 -> $location"
+		debug-print "inherit: ${1} -> ${location}"
 		[[ -z ${location} ]] && die "${1}.eclass could not be found by inherit()"
 
 		# Inherits in QA checks can't handle metadata assignments
@@ -287,11 +287,11 @@ inherit() {
 				unset RESTRICT
 			fi
 
-			#turn on glob expansion
+			# Turn on glob expansion
 			set +f
 		fi
 
-		__qa_source "$location" || die "died sourcing $location in inherit()"
+		__qa_source "${location}" || die "died sourcing ${location} in inherit()"
 
 		if [[ -z ${_IN_INSTALL_QA_CHECK} ]]; then
 			# Turn off glob expansion
@@ -350,15 +350,15 @@ inherit() {
 
 			if [[ -n ${!__export_funcs_var} ]] ; then
 				for x in ${!__export_funcs_var} ; do
-					debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
-					declare -F "${ECLASS}_$x" >/dev/null || \
-						die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
-					eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
+					debug-print "EXPORT_FUNCTIONS: ${x} -> ${ECLASS}_${x}"
+					declare -F "${ECLASS}_${x}" >/dev/null || \
+						die "EXPORT_FUNCTIONS: ${ECLASS}_${x} is not defined"
+					eval "$x() { ${ECLASS}_${x} \"\$@\" ; }" > /dev/null
 				done
 			fi
 			unset $__export_funcs_var
 
-			has $1 $INHERITED || export INHERITED="$INHERITED $1"
+			has $1 ${INHERITED} || export INHERITED="${INHERITED} $1"
 			if [[ ${ECLASS_DEPTH} -eq 1 ]]; then
 				export PORTAGE_EXPLICIT_INHERIT="${PORTAGE_EXPLICIT_INHERIT} $1"
 			fi
@@ -375,10 +375,10 @@ inherit() {
 # code will be eval'd:
 # src_unpack() { base_src_unpack; }
 EXPORT_FUNCTIONS() {
-	if [[ -z "$ECLASS" ]]; then
+	if [[ -z "${ECLASS}" ]]; then
 		die "EXPORT_FUNCTIONS without a defined ECLASS"
 	fi
-	eval $__export_funcs_var+=\" $*\"
+	eval ${__export_funcs_var}+=\" $*\"
 }
 
 PORTAGE_BASHRCS_SOURCED=0
@@ -395,24 +395,25 @@ PORTAGE_BASHRCS_SOURCED=0
 #    function for the current phase.
 #
 __source_all_bashrcs() {
-	[[ $PORTAGE_BASHRCS_SOURCED = 1 ]] && return 0
+	[[ ${PORTAGE_BASHRCS_SOURCED} = 1 ]] && return 0
+
 	PORTAGE_BASHRCS_SOURCED=1
-	local x
 
+	local x
 	local OCC="${CC}" OCXX="${CXX}"
 
-	if [[ $EBUILD_PHASE != depend ]] ; then
-		# source the existing profile.bashrcs.
+	if [[ ${EBUILD_PHASE} != depend ]] ; then
+		# Source the existing profile.bashrcs.
 		while read -r x; do
 			__try_source "${x}"
 		done <<<"${PORTAGE_BASHRC_FILES}"
 	fi
 
-	# The user's bashrc is the ONLY non-portage bit of code
+	# The user's bashrc is the ONLY non-Portage bit of code
 	# that can change shopts without a QA violation.
 	__try_source --no-qa "${PORTAGE_BASHRC}"
 
-	if [[ $EBUILD_PHASE != depend ]] ; then
+	if [[ ${EBUILD_PHASE} != depend ]] ; then
 		__source_env_files --no-qa "${PM_EBUILD_HOOK_DIR}"
 	fi
 
@@ -428,10 +429,11 @@ __source_all_bashrcs() {
 # files.
 __source_env_files() {
 	local argument=()
-	if [[ $1 == --no-qa ]]; then
+	if [[ ${1} == --no-qa ]]; then
 		argument=( --no-qa )
-	shift
+		shift
 	fi
+
 	for x in "${1}"/${CATEGORY}/{${PN},${PN}:${SLOT%/*},${P},${PF}}; do
 		__try_source "${argument[@]}" "${x}"
 	done
@@ -445,25 +447,28 @@ __source_env_files() {
 # If --no-qa is specified, source the file with source instead of __qa_source.
 __try_source() {
 	local qa=true
-	if [[ $1 == --no-qa ]]; then
+	if [[ ${1} == --no-qa ]]; then
 		qa=false
 		shift
 	fi
-	if [[ -r $1 && -f $1 ]]; then
+
+	if [[ -r ${1} && -f ${1} ]]; then
 		local debug_on=false
-		if [[ "$PORTAGE_DEBUG" == "1" ]] && [[ "${-/x/}" == "$-" ]]; then
+
+		if [[ "${PORTAGE_DEBUG}" == "1" ]] && [[ "${-/x/}" == "$-" ]]; then
 			debug_on=true
 		fi
-		$debug_on && set -x
+
+		${debug_on} && set -x
 		# If $- contains x, then tracing has already been enabled
-		# elsewhere for some reason. We preserve it's state so as
+		# elsewhere for some reason. We preserve its state so as
 		# not to interfere.
 		if ! ${qa} ; then
 			source "${1}"
 		else
 			__qa_source "${1}"
 		fi
-		$debug_on && set +x
+		${debug_on} && set +x
 	fi
 }
 # === === === === === === === === === === === === === === === === === ===
@@ -497,7 +502,7 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then
 		fi
 		if [[ ${EBUILD_PHASE} == depend ]] ; then
 			FUNC_SRC="${BIN}() {
-				if [[ \$ECLASS_DEPTH -gt 0 ]]; then
+				if [[ \${ECLASS_DEPTH} -gt 0 ]]; then
 					eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
 				else
 					eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
@@ -521,7 +526,7 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then
 			${BODY}
 			}"
 		fi
-		eval "$FUNC_SRC" || echo "error creating QA interceptor ${BIN}" >&2
+		eval "${FUNC_SRC}" || echo "error creating QA interceptor ${BIN}" >&2
 	done
 	unset BIN_PATH BIN BODY FUNC_SRC
 fi
@@ -530,23 +535,22 @@ fi
 export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
 trap 'exit 1' SIGTERM
 
-if ! has "$EBUILD_PHASE" clean cleanrm depend && \
-	! [[ $EMERGE_FROM = ebuild && $EBUILD_PHASE = setup ]] && \
-	[[ -f "${T}"/environment ]]; then
+if ! has "${EBUILD_PHASE}" clean cleanrm depend && ! [[ ${EMERGE_FROM} = ebuild && ${EBUILD_PHASE} = setup ]] && [[ -f "${T}"/environment ]]; then
 	# The environment may have been extracted from environment.bz2 or
 	# may have come from another version of ebuild.sh or something.
 	# In any case, preprocess it to prevent any potential interference.
 	# NOTE: export ${FOO}=... requires quoting, unlike normal exports
-	__preprocess_ebuild_env || \
-		die "error processing environment"
+	__preprocess_ebuild_env || die "error processing environment"
+
 	# Colon separated SANDBOX_* variables need to be cumulative.
 	for x in SANDBOX_DENY SANDBOX_READ SANDBOX_PREDICT SANDBOX_WRITE ; do
 		export PORTAGE_${x}="${!x}"
 	done
 	PORTAGE_SANDBOX_ON=${SANDBOX_ON}
 	export SANDBOX_ON=1
-	source "${T}"/environment || \
-		die "error sourcing environment"
+
+	source "${T}"/environment || die "error sourcing environment"
+
 	# We have to temporarily disable sandbox since the
 	# SANDBOX_{DENY,READ,PREDICT,WRITE} values we've just loaded
 	# may be unusable (triggering in spurious sandbox violations)
@@ -557,17 +561,18 @@ if ! has "$EBUILD_PHASE" clean cleanrm depend && \
 		if [[ -z "${!x}" ]]; then
 			export ${x}="${!y}"
 		elif [[ -n "${!y}" && "${!y}" != "${!x}" ]]; then
-			# filter out dupes
+			# Filter out dupes
 			export ${x}="$(printf "${!y}:${!x}" | tr ":" "\0" | \
 				sort -z -u | tr "\0" ":")"
 		fi
 		export ${x}="${!x%:}"
 		unset PORTAGE_${x}
 	done
+
 	unset x y
 	export SANDBOX_ON=${PORTAGE_SANDBOX_ON}
 	unset PORTAGE_SANDBOX_ON
-	[[ -n $EAPI ]] || EAPI=0
+	[[ -n ${EAPI} ]] || EAPI=0
 fi
 
 # Convert quoted paths to array.
@@ -575,11 +580,9 @@ eval "PORTAGE_ECLASS_LOCATIONS=(${PORTAGE_ECLASS_LOCATIONS})"
 
 # Source the ebuild every time for FEATURES=noauto, so that ebuild
 # modifications take effect immediately.
-if ! has "$EBUILD_PHASE" clean cleanrm ; then
-	if [[ $EBUILD_PHASE = setup && $EMERGE_FROM = ebuild ]] || \
-		[[ $EBUILD_PHASE = depend || ! -f $T/environment || \
-		-f $PORTAGE_BUILDDIR/.ebuild_changed || \
-		" ${FEATURES} " == *" noauto "* ]] ; then
+if ! has "${EBUILD_PHASE}" clean cleanrm ; then
+	if [[ ${EBUILD_PHASE} = setup && ${EMERGE_FROM} = ebuild ]] || \
+	[[ ${EBUILD_PHASE} = depend || ! -f ${T}/environment || -f ${PORTAGE_BUILDDIR}/.ebuild_changed || " ${FEATURES} " == *" noauto "* ]] ; then
 		# The bashrcs get an opportunity here to set aliases that will be expanded
 		# during sourcing of ebuilds and eclasses.
 		__source_all_bashrcs
@@ -588,7 +591,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
 		# from cache. In order to make INHERITED content independent of
 		# EBUILD_PHASE during inherit() calls, we unset INHERITED after
 		# we make a backup copy for QA checks.
-		__INHERITED_QA_CACHE=$INHERITED
+		__INHERITED_QA_CACHE=${INHERITED}
 
 		# Catch failed globbing attempts in case ebuild writer forgot to
 		# escape '*' or likes.
@@ -607,11 +610,11 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
 		unset E_RESTRICT PROVIDES_EXCLUDE REQUIRES_EXCLUDE
 		unset PORTAGE_EXPLICIT_INHERIT
 
-		if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then
-			source "$EBUILD" || die "error sourcing ebuild"
+		if [[ ${PORTAGE_DEBUG} != 1 || ${-/x/} != $- ]] ; then
+			source "${EBUILD}" || die "error sourcing ebuild"
 		else
 			set -x
-			source "$EBUILD" || die "error sourcing ebuild"
+			source "${EBUILD}" || die "error sourcing ebuild"
 			set +x
 		fi
 
@@ -651,11 +654,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
 		if [[ "${EBUILD_PHASE}" != "depend" ]] ; then
 			PROPERTIES=${PORTAGE_PROPERTIES}
 			RESTRICT=${PORTAGE_RESTRICT}
-			[[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \
-			rm "$PORTAGE_BUILDDIR/.ebuild_changed"
+			[[ -e ${PORTAGE_BUILDDIR}/.ebuild_changed ]] && rm "${PORTAGE_BUILDDIR}/.ebuild_changed"
 		fi
 
-		# alphabetically ordered by $EBUILD_PHASE value
+		# alphabetically ordered by ${EBUILD_PHASE} value
 		case ${EAPI} in
 			0|1)
 				_valid_phases="src_compile pkg_config pkg_info src_install
@@ -675,41 +677,39 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
 		esac
 
 		DEFINED_PHASES=
-		for _f in $_valid_phases ; do
-			if declare -F $_f >/dev/null ; then
+		for _f in ${_valid_phases} ; do
+			if declare -F ${_f} >/dev/null ; then
 				_f=${_f#pkg_}
 				DEFINED_PHASES+=" ${_f#src_}"
 			fi
 		done
-		[[ -n $DEFINED_PHASES ]] || DEFINED_PHASES=-
+		[[ -n ${DEFINED_PHASES} ]] || DEFINED_PHASES=-
 
 		unset _f _valid_phases
 
-		if [[ $EBUILD_PHASE != depend ]] ; then
+		if [[ ${EBUILD_PHASE} != depend ]] ; then
 
-			if has distcc $FEATURES ; then
-				[[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}"
+			if has distcc ${FEATURES} ; then
+				[[ -n ${DISTCC_LOG} ]] && addwrite "${DISTCC_LOG%/*}"
 			fi
 
-			if has ccache $FEATURES ; then
-
-				if [[ -n $CCACHE_DIR ]] ; then
-					addread "$CCACHE_DIR"
-					addwrite "$CCACHE_DIR"
+			if has ccache ${FEATURES} ; then
+				if [[ -n ${CCACHE_DIR} ]] ; then
+					addread "${CCACHE_DIR}"
+					addwrite "${CCACHE_DIR}"
 				fi
 
-				[[ -n $CCACHE_SIZE ]] && ccache -M $CCACHE_SIZE &> /dev/null
+				[[ -n ${CCACHE_SIZE} ]] && ccache -M ${CCACHE_SIZE} &> /dev/null
 			fi
 		fi
 	fi
 fi
 
-if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}
-then
+if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT} ; then
 	export DEBUGBUILD=1
 fi
 
-if [[ $EBUILD_PHASE = depend ]] ; then
+if [[ ${EBUILD_PHASE} = depend ]] ; then
 	export SANDBOX_ON="0"
 	set -f
 
@@ -737,10 +737,11 @@ if [[ $EBUILD_PHASE = depend ]] ; then
 else
 	# Note: readonly variables interfere with __preprocess_ebuild_env(), so
 	# declare them only after it has already run.
-	declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS
+	declare -r ${PORTAGE_READONLY_METADATA} ${PORTAGE_READONLY_VARS}
 	if ___eapi_has_prefix_variables; then
 		declare -r ED EPREFIX EROOT
 	fi
+
 	if ___eapi_has_BROOT; then
 		declare -r BROOT
 	fi
@@ -749,11 +750,12 @@ else
 	# then it might not have USE=test like it's supposed to here.
 	if [[ ${EBUILD_PHASE} == test && ${EBUILD_FORCE_TEST} == 1 ]] &&
 		___in_portage_iuse test && ! has test ${USE} ; then
+
 		export USE="${USE} test"
 	fi
 	declare -r USE
 
-	if [[ -n $EBUILD_SH_ARGS ]] ; then
+	if [[ -n ${EBUILD_SH_ARGS} ]] ; then
 		(
 			# Don't allow subprocesses to inherit the pipe which
 			# emerge uses to monitor ebuild.sh.

diff --git a/bin/ecompress b/bin/ecompress
index 30d7888cd..0aa5091dd 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -129,20 +129,24 @@ fi
 
 guess_suffix() {
 	set -e
+
 	tmpdir="${T}"/.ecompress$$.${RANDOM}
 	mkdir "${tmpdir}"
 	cd "${tmpdir}"
-	# we have to fill the file enough so that there is something
+
+	# We have to fill the file enough so that there is something
 	# to compress as some programs will refuse to do compression
 	# if it cannot actually compress the file
 	echo {0..1000} > compressme
 	${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS} compressme > /dev/null
+
 	# If PORTAGE_COMPRESS_FLAGS contains -k then we need to avoid
 	# having our glob match the uncompressed file here.
 	suffix=$(echo compressme.*)
-	[[ -z $suffix || "$suffix" == "compressme.*" ]] && \
+	[[ -z ${suffix} || "${suffix}" == "compressme.*" ]] && \
 		suffix=$(echo compressme*)
 	suffix=${suffix#compressme}
+
 	cd /
 	rm -rf "${tmpdir}"
 	echo "${suffix}"
@@ -159,6 +163,7 @@ fix_symlinks() {
 	local something_changed=
 	while read -r -d $'\0' brokenlink ; do
 		[[ -e ${brokenlink} ]] && continue
+
 		olddest=$(readlink "${brokenlink}")
 		newdest=${olddest}${PORTAGE_COMPRESS_SUFFIX}
 		if [[ "${newdest}" == /* ]] ; then
@@ -166,6 +171,7 @@ fix_symlinks() {
 		else
 			[[ -f "${brokenlink%/*}/${newdest}" ]] || continue
 		fi
+
 		something_changed=${brokenlink}
 		rm -f "${brokenlink}" &&
 		ln -snf "${newdest}" "${brokenlink}${PORTAGE_COMPRESS_SUFFIX}"
@@ -174,6 +180,7 @@ fix_symlinks() {
 
 	[[ -n ${something_changed} ]] || break
 	(( indirection++ ))
+
 	if (( indirection >= 100 )) ; then
 		# Protect against possibility of a bug triggering an endless loop.
 		eerror "ecompress: too many levels of indirection for" \
@@ -207,6 +214,6 @@ fi
 
 fix_symlinks
 : $(( ret |= ${?} ))
-[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 
 exit ${ret}

diff --git a/bin/ecompress-file b/bin/ecompress-file
index 1943ca102..3cee5f90a 100755
--- a/bin/ecompress-file
+++ b/bin/ecompress-file
@@ -6,19 +6,21 @@ source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 compress_file() {
 	mask_ext_re=""
+
 	set -f
 	local x
-	for x in $PORTAGE_COMPRESS_EXCLUDE_SUFFIXES ; do
-		mask_ext_re+="|$x"
+	for x in ${PORTAGE_COMPRESS_EXCLUDE_SUFFIXES} ; do
+		mask_ext_re+="|${x}"
 	done
 	set +f
+
 	mask_ext_re="^(${mask_ext_re:1})\$"
 	local filtered_args=()
 	for x in "$@" ; do
-		[[ ${x##*.} =~ $mask_ext_re ]] && continue
+		[[ ${x##*.} =~ ${mask_ext_re} ]] && continue
 		[[ -s ${x} ]] || continue
 
-		# handle precompressed files
+		# Handle precompressed files
 		case ${x} in
 			*.gz|*.Z)
 				gunzip -f "${x}" || __helpers_die "gunzip failed"
@@ -34,7 +36,7 @@ compress_file() {
 				x=${x%.lz};;
 		esac
 
-		filtered_args+=( "$x" )
+		filtered_args+=( "${x}" )
 	done
 	[[ ${#filtered_args[@]} -eq 0 ]] && return 0
 	set -- "${filtered_args[@]}"
@@ -53,8 +55,9 @@ compress_file() {
 
 	# Finally, let's actually do some real work
 	"${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@"
+
 	ret=$?
-	[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+	[[ ${ret} -ne 0 ]] && __helpers_die "${0##*/} failed"
 	return ${ret}
 }
 

diff --git a/bin/egencache b/bin/egencache
index 842f453ea..4d920ea3b 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -879,10 +879,10 @@ class GenChangeLogs:
         # --work-tree=... must be passed to Git if GIT_DIR is used
         # and GIT_DIR is not a child of the root of the checkout
         # eg:
-        # GIT_DIR=$parent/work/.git/
-        # work-tree=$parent/staging/
+        # GIT_DIR=${parent}/work/.git/
+        # work-tree=${parent}/staging/
         # If work-tree is not passed, Git tries to use the shared
-        # parent of the current directory and the $GIT_DIR, which can
+        # parent of the current directory and the ${GIT_DIR}, which can
         # be outside the root of the checkout.
         self._work_tree = "--work-tree=%s" % self._repo_path
 
@@ -960,7 +960,7 @@ class GenChangeLogs:
             # --no-renames to avoid getting more complex records on the list
             # --format to get the timestamp, author and commit description
             # --root to make it work fine even with the initial commit
-            # --relative=$cp to get paths relative to ebuilddir
+            # --relative=${cp} to get paths relative to ebuilddir
             # -r (recursive) to get per-file changes
             # then the commit-id and path.
 

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 811bfccb7..7fb98900d 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -20,8 +20,8 @@
 # Alternative (legacy) PORTAGE_GPG_DIR configuration:
 # gpg key import
 # KEY_ID=0x96D8BF6D
-# gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys $KEY_ID
-# gpg --homedir /etc/portage/gnupg --edit-key $KEY_ID trust
+# gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys ${KEY_ID}
+# gpg --homedir /etc/portage/gnupg --edit-key ${KEY_ID} trust
 #
 
 # Only echo if in verbose mode
@@ -46,6 +46,7 @@ else
 	eecho "could not find 'portageq'; aborting"
 	exit 1
 fi
+
 eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
 	FETCHCOMMAND GENTOO_MIRRORS \
 	PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \
@@ -67,7 +68,7 @@ repo_sync_type=$(__repo_attr "${repo_name}" sync-type)
 # If PORTAGE_NICENESS is overriden via the env then it will
 # still pass through the portageq call and override properly.
 if [ -n "${PORTAGE_NICENESS}" ]; then
-	renice $PORTAGE_NICENESS $$ > /dev/null
+	renice ${PORTAGE_NICENESS} $$ > /dev/null
 fi
 
 do_verbose=0
@@ -83,6 +84,7 @@ fi
 if [[ -n ${PORTAGE_TEMP_GPG_DIR} ]] ||
 	has $(__repo_attr "${repo_name}" sync-webrsync-verify-signature |
 	LC_ALL=C tr '[:upper:]' '[:lower:]') true yes; then
+
 	# If FEATURES=webrsync-gpg is enabled then allow direct emerge-webrsync
 	# calls for backward compatibility (this triggers a deprecation warning
 	# above). Since direct emerge-webrsync calls do not use gemato for secure
@@ -92,12 +94,14 @@ if [[ -n ${PORTAGE_TEMP_GPG_DIR} ]] ||
 		eecho "Do not call ${argv0##*/} directly, instead call emerge --sync or emaint sync."
 		exit 1
 	fi
+
 	WEBSYNC_VERIFY_SIGNATURE=1
 elif has webrsync-gpg ${FEATURES}; then
 	WEBSYNC_VERIFY_SIGNATURE=1
 else
 	WEBSYNC_VERIFY_SIGNATURE=0
 fi
+
 [[ -n ${PORTAGE_TEMP_GPG_DIR} ]] && PORTAGE_GPG_DIR=${PORTAGE_TEMP_GPG_DIR}
 if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
 	eecho "please set PORTAGE_GPG_DIR in make.conf"
@@ -105,8 +109,10 @@ if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
 fi
 
 do_tar() {
-	local file=$1; shift
+	local file=$1
+	shift
 	local decompressor
+
 	case ${file} in
 		*.xz)   decompressor="xzcat" ;;
 		*.bz2)  decompressor="bzcat" ;;
@@ -126,7 +132,7 @@ get_date_part() {
 	local utc_time_in_secs="$1"
 	local part="$2"
 
-	if	[[ ${USERLAND} == BSD ]] ; then
+	if [[ ${USERLAND} == BSD ]] ; then
 		date -r ${utc_time_in_secs} -u +"${part}"
 	else
 		date -d @${utc_time_in_secs} -u +"${part}"
@@ -135,6 +141,7 @@ get_date_part() {
 
 get_utc_second_from_string() {
 	local s="$1"
+
 	if [[ ${USERLAND} == BSD ]] ; then
 		# Specify zeros for the least significant digits, or else those
 		# digits are inherited from the current system clock time.
@@ -168,8 +175,9 @@ fetch_file() {
 	fi
 
 	__vecho "Fetching file ${FILE} ..."
-	# already set DISTDIR=
+	# Already set DISTDIR=
 	eval "${FETCHCOMMAND} ${opts}"
+
 	if [[ $? -eq 0 && -s ${DISTDIR}/${FILE} ]] ; then
 		return 0
 	else
@@ -205,7 +213,6 @@ check_file_signature() {
 	local gnupg_status line
 
 	if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]; then
-
 		__vecho "Checking signature ..."
 
 		if type -P gpg > /dev/null; then
@@ -218,6 +225,7 @@ check_file_signature() {
 					fi
 				done <<< "${gnupg_status}"
 			fi
+
 			if [[ ${r} -ne 0 ]]; then
 				# Exit early since it's typically inappropriate to
 				# try other mirrors in this case (it may indicate
@@ -262,8 +270,10 @@ sync_local() {
 	if type -P tarsync > /dev/null ; then
 		local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
 		chown ${ownership} "${repo_location}" > /dev/null 2>&1 || chown_opts=""
+
 		if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \
 			-e /distfiles -e /packages -e /local "${file}" "${repo_location}"; then
+
 			eecho "tarsync failed; tarball is corrupt? (${file})"
 			return 1
 		fi
@@ -281,6 +291,7 @@ sync_local() {
 			chown -R ${ownership} .
 			rsync_opts+=" --owner --group"
 		fi
+
 		chmod 755 .
 		rsync ${rsync_opts} . "${repo_location%%/}"
 
@@ -291,8 +302,10 @@ sync_local() {
 		__vecho "Updating cache ..."
 		emerge --metadata
 	fi
+
 	local post_sync=${PORTAGE_CONFIGROOT}etc/portage/bin/post_sync
 	[ -x "${post_sync}" ] && "${post_sync}"
+
 	# --quiet suppresses output if there are no relevant news items
 	has news ${FEATURES} && emerge --check-news --quiet
 	return 0
@@ -310,16 +323,17 @@ do_snapshot() {
 	local mirror
 
 	local compressions=""
+
 	type -P xzcat > /dev/null && compressions="${compressions} ${repo_name}:xz portage:xz"
 	type -P bzcat > /dev/null && compressions="${compressions} ${repo_name}:bz2 portage:bz2"
 	type -P  zcat > /dev/null && compressions="${compressions} ${repo_name}:gz portage:gz"
+
 	if [[ -z ${compressions} ]] ; then
 		eecho "unable to locate any decompressors (xzcat or bzcat or zcat)"
 		exit 1
 	fi
 
 	for mirror in ${GENTOO_MIRRORS} ; do
-
 		mirror=${mirror%/}
 		__vecho "Trying to retrieve ${date} snapshot from ${mirror} ..."
 
@@ -351,7 +365,6 @@ do_snapshot() {
 			# from a different mirror
 			#
 			if [ ${have_files} -eq 1 ]; then
-
 				__vecho "Getting snapshot timestamp ..."
 				local snapshot_timestamp=$(get_snapshot_timestamp "${DISTDIR}/${file}")
 

diff --git a/bin/estrip b/bin/estrip
index 63bd46eb1..6935470d3 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -6,7 +6,7 @@ source "${PORTAGE_BIN_PATH}"/helper-functions.sh || exit 1
 
 # avoid multiple calls to `has`.  this creates things like:
 #   FEATURES_foo=false
-# if "foo" is not in $FEATURES
+# if "foo" is not in ${FEATURES}
 tf() { "$@" && echo true || echo false ; }
 exp_tf() {
 	local flag var=$1
@@ -104,6 +104,7 @@ if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then
 			"${PORTAGE_PYTHON:-/usr/bin/python}" \
 			"${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo -n "$1")
 		}
+
 		restore_xattrs() {
 			PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
 			"${PORTAGE_PYTHON:-/usr/bin/python}" \
@@ -112,7 +113,7 @@ if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then
 	fi
 fi
 
-# look up the tools we might be using
+# Look up the tools we might be using
 for t in STRIP:strip OBJCOPY:objcopy READELF:readelf RANLIB:ranlib ; do
 	v=${t%:*} # STRIP
 	t=${t#*:} # strip
@@ -147,6 +148,7 @@ if [[ -z ${debugedit} ]]; then
 	debugedit_paths=(
 		"${EPREFIX}/usr/libexec/rpm/debugedit"
 	)
+
 	for x in "${debugedit_paths[@]}"; do
 		if [[ -x ${x} ]]; then
 			debugedit=${x}
@@ -159,7 +161,7 @@ debugedit_warned=false
 
 __multijob_init
 
-# Setup $T filesystem layout that we care about.
+# Setup ${T} filesystem layout that we care about.
 tmpdir="${T}/prepstrip"
 rm -rf "${tmpdir}"
 mkdir -p "${tmpdir}"/{inodes,splitdebug,sources}
@@ -168,6 +170,7 @@ mkdir -p "${tmpdir}"/{inodes,splitdebug,sources}
 save_elf_sources() {
 	${FEATURES_installsources} || return 0
 	${PORTAGE_RESTRICT_installsources} && return 0
+
 	if ! ${debugedit_found} ; then
 		if ! ${debugedit_warned} ; then
 			debugedit_warned=true
@@ -194,6 +197,7 @@ save_elf_sources() {
 __try_symlink() {
 	local target=$1
 	local name=$2
+
 	# Check for an existing link before and after in case we are racing against
 	# another process.
 	[[ -L ${name} ]] ||
@@ -251,20 +255,23 @@ save_elf_debug() {
 			${OBJCOPY} ${objcopy_flags} "${src}" "${dst}" &&
 			${OBJCOPY} --add-gnu-debuglink="${dst}" "${src}"
 		fi
+
 		# Only do the following if the debug file was
 		# successfully created (see bug #446774).
 		if [[ $? -eq 0 ]] ; then
 			local args="a-x,o-w"
 			[[ -g ${src} || -u ${src} ]] && args+=",go-r"
 			chmod ${args} "${dst}"
-			# symlink so we can read the name back.
+
+			# Symlink so we can read the name back.
 			__try_symlink "${dst}" "${inode_debug}"
 
-			# if we don't already have build-id from debugedit, look it up
+			# If we don't already have build-id from debugedit, look it up
 			if [[ -z ${buildid} ]] ; then
 				# convert the readelf output to something useful
 				buildid=$(${READELF} -n "${src}" 2>/dev/null | awk '/Build ID:/{ print $NF; exit }')
 			fi
+
 			if [[ -n ${buildid} ]] ; then
 				local buildid_dir="${ED%/}/usr/lib/debug/.build-id/${buildid:0:2}"
 				local buildid_file="${buildid_dir}/${buildid:2}"
@@ -309,11 +316,11 @@ process_elf() {
 	fi
 
 	if ${strip_this} ; then
-
-		# see if we can split & strip at the same time
+		# See if we can split & strip at the same time
 		if [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then
 			local shortname="${x##*/}.debug"
 			local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID:-$(__bashpid)}"
+
 			${already_stripped} || \
 			${STRIP} ${strip_flags} \
 				-f "${splitdebug}" \
@@ -322,8 +329,7 @@ process_elf() {
 			save_elf_debug "${x}" "${inode_link}_debug" "${splitdebug}"
 		else
 			save_elf_debug "${x}" "${inode_link}_debug"
-			${already_stripped} || \
-			${STRIP} ${strip_flags} "${x}"
+			${already_stripped} || ${STRIP} ${strip_flags} "${x}"
 		fi
 	fi
 
@@ -367,6 +373,7 @@ if ! ${PORTAGE_RESTRICT_binchecks} ; then
 	# parallel though.
 	log=${tmpdir}/scanelf-already-stripped.log
 	scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^${ED%/}/##" > "${log}"
+
 	(
 	__multijob_child_init
 	qa_var="QA_PRESTRIPPED_${ARCH/-/_}"
@@ -402,7 +409,9 @@ if  [[ ${USERLAND} == BSD ]] ; then
 else
 	get_inode_number() { stat -c '%i' "$1"; }
 fi
+
 cd "${tmpdir}/inodes" || die "cd failed unexpectedly"
+
 if ${prepstrip}; then
 while read -r x ; do
 	inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly"
@@ -443,8 +452,8 @@ do
 		strip_this=true
 	else
 		# The noglob funk is to support STRIP_MASK="/*/booga" and to keep
-		#  the for loop from expanding the globs.
-		# The eval echo is to support STRIP_MASK="/*/{booga,bar}" sex.
+		# the for loop from expanding the globs.
+		# The eval echo is to support STRIP_MASK="/*/{booga,bar}".
 		set -o noglob
 		strip_this=true
 		for m in $(eval echo ${STRIP_MASK}) ; do
@@ -466,7 +475,7 @@ do
 	# or kernel modules as debuginfo for intermediatary
 	# files (think crt*.o from gcc/glibc) is useless and
 	# actually causes problems.  install sources for all
-	# elf types though cause that stuff is good.
+	# elf types though because that stuff is good.
 
 	buildid=
 	if [[ ${f} == *"current ar archive"* ]] ; then
@@ -499,8 +508,9 @@ if [[ -s ${tmpdir}/debug.sources ]] && \
 then
 	__vecho "installsources: rsyncing source files"
 	[[ -d ${D%/}/${prepstrip_sources_dir#/} ]] || mkdir -p "${D%/}/${prepstrip_sources_dir#/}"
-	# skip installation of ".../<foo>" (system headers? why inner slashes are forbidden?)
-	# skip syncing of ".../foo/" (complete directories)
+
+	# Skip installation of ".../<foo>" (system headers? why inner slashes are forbidden?)
+	# Skip syncing of ".../foo/" (complete directories)
 	grep -zv -e '/<[^/>]*>$' -e '/$' "${tmpdir}"/debug.sources | \
 		(cd "${WORKDIR}"; LANG=C sort -z -u | \
 		rsync -tL0 --chmod=ugo-st,a+r,go-w,Da+x,Fa-x --files-from=- "${WORKDIR}/" "${D%/}/${prepstrip_sources_dir#/}/" )
@@ -508,8 +518,7 @@ then
 	# Preserve directory structure.
 	# Needed after running save_elf_sources.
 	# https://bugzilla.redhat.com/show_bug.cgi?id=444310
-	while read -r -d $'\0' emptydir
-	do
+	while read -r -d $'\0' emptydir; do
 		>> "${emptydir}"/.keepdir
 	done < <(find "${D%/}/${prepstrip_sources_dir#/}/" -type d -empty -print0)
 fi

diff --git a/bin/etc-update b/bin/etc-update
index 148a0f05a..a7d1088da 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -41,7 +41,7 @@ case ${OS_RELEASE_POSSIBLE_IDS} in
 	*) OS_FAMILY='gentoo';;
 esac
 
-if [[ $OS_FAMILY == 'gentoo' ]]; then
+if [[ ${OS_FAMILY} == 'gentoo' ]]; then
 	get_basename() {
 		printf -- '%s\n' "${1:10}"
 	}
@@ -54,7 +54,7 @@ if [[ $OS_FAMILY == 'gentoo' ]]; then
 	get_live_file() {
 		echo "${rpath}/${rfile:10}"
 	}
-elif [[ $OS_FAMILY == 'arch' ]]; then
+elif [[ ${OS_FAMILY} == 'arch' ]]; then
 	get_basename() {
 		printf -- '%s\n' "${1%.${NEW_EXT}}"
 	}
@@ -68,7 +68,7 @@ elif [[ $OS_FAMILY == 'arch' ]]; then
 		printf -- '%s\n' "${cfg_file%.${NEW_EXT}}"
 	}
 # In rpm we have rpmsave, rpmorig, and rpmnew.
-elif [[ $OS_FAMILY == 'rpm' ]]; then
+elif [[ ${OS_FAMILY} == 'rpm' ]]; then
 	get_basename() {
 		printf -- '%s\n' "${1}" |sed -e 's/\.rpmsave$//' -e 's/\.rpmnew$//' -e 's/\.rpmorig$//'
 	}
@@ -133,6 +133,7 @@ scan() {
 			# parent directory doesn't exist, we can safely skip it.
 			path=${path%/}
 			[[ -d ${path%/*} ]] || continue
+
 			local name_opt=$(get_basename_find_opt "${path##*/}")
 			path="${path%/*}"
 			find_opts=( -maxdepth 1 )
@@ -141,9 +142,10 @@ scan() {
 			local name_opt=$(get_basename_find_opt '*')
 			find_opts=( -name '.*' -type d -prune -o )
 		fi
+
 		${case_insensitive} && \
 			find_opts+=( -iname ) || find_opts+=( -name )
-		find_opts+=( "$name_opt" )
+		find_opts+=( "${name_opt}" )
 		find_opts+=( ! -name '.*~' ! -iname '.*.bak' -print )
 
 		if [[ ! -w ${path} ]] ; then
@@ -157,8 +159,8 @@ scan() {
 		              sed \
 						-e 's://*:/:g' \
 						-e "${scan_regexp}" |
-		              sort -t"$b" -k2,2 -k4,4 -k3,3 |
-		              LC_ALL=C cut -f1 -d"$b")
+		              sort -t"${b}" -k2,2 -k4,4 -k3,3 |
+		              LC_ALL=C cut -f1 -d"${b}")
 		do
 			local rpath rfile cfg_file live_file
 			rpath=${file%/*}
@@ -175,6 +177,7 @@ scan() {
 					continue 2
 				fi
 			done
+
 			if [[ -L ${file} ]] ; then
 				if [[ -L ${live_file} && \
 					$(readlink "${live_file}") == $(readlink "${file}") ]]
@@ -182,17 +185,20 @@ scan() {
 					rm -f "${file}"
 					continue
 				fi
+
 				if [[ $(get_basename "${ofile}") != $(get_basename "${rfile}") ]] ||
 				   [[ ${opath} != ${rpath} ]]
 				then
 					: $(( ++count ))
 					echo "${live_file}" > "${TMP}"/files/${count}
 				fi
+
 				echo "${cfg_file}" >> "${TMP}"/files/${count}
 				ofile="${rfile}"
 				opath="${rpath}"
 				continue
 			fi
+
 			if [[ ! -f ${file} ]] ; then
 				${QUIET} || echo "Skipping non-file ${file} ..."
 				continue
@@ -202,6 +208,7 @@ scan() {
 			   [[ ${opath} != ${rpath} ]]
 			then
 				MATCHES=0
+
 				if ! [[ -f ${cfg_file} && -f ${live_file} ]] ; then
 					MATCHES=0
 				elif [[ ${eu_automerge} == "yes" ]] ; then
@@ -594,7 +601,7 @@ do_merge() {
 		rm ${rm_opts} "${mfile}"
 	fi
 
-	# since mfile will be like $TMP/path/to/original-file.merged, we
+	# since mfile will be like ${TMP}/path/to/original-file.merged, we
 	# need to make sure the full /path/to/ exists ahead of time
 	mkdir -p "${mfile%/*}"
 
@@ -769,13 +776,13 @@ while [[ -n $1 ]] ; do
 done
 ${SET_X} && set -x
 
-if [[ $OS_FAMILY == 'rpm' ]]; then
+if [[ ${OS_FAMILY} == 'rpm' ]]; then
 	PORTAGE_CONFIGROOT='/'
 	PORTAGE_TMPDIR='/tmp'
 	CONFIG_PROTECT='/etc /usr/share'
 	CONFIG_PROTECT_MASK=''
 	[[ -f /etc/sysconfig/etc-update ]] && . /etc/sysconfig/etc-update
-elif [[ $OS_FAMILY == 'arch' ]]; then
+elif [[ ${OS_FAMILY} == 'arch' ]]; then
 	PORTAGE_CONFIGROOT='/'
 	PORTAGE_TMPDIR='/tmp'
 	CONFIG_PROTECT='/etc /usr/lib /usr/share/config'
@@ -796,7 +803,7 @@ portage_vars=(
 if type -P portageq > /dev/null; then
 	eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "$(type -P portageq)" envvar -v "${portage_vars[@]}")
 else
-	[[ $OS_FAMILY == 'gentoo' ]] && die "missing portageq"
+	[[ ${OS_FAMILY} == 'gentoo' ]] && die "missing portageq"
 fi
 
 export PORTAGE_TMPDIR

diff --git a/bin/install-qa-check.d/05prefix b/bin/install-qa-check.d/05prefix
index c1a5606d8..7488ad9e4 100644
--- a/bin/install-qa-check.d/05prefix
+++ b/bin/install-qa-check.d/05prefix
@@ -65,7 +65,7 @@ install_qa_check_prefix() {
 		# does the shebang start with ${EPREFIX}, and does it exist?
 		if [[ ${line[0]} == ${EPREFIX}/* || ${line[0]} == ${eprefix}/* ]] ; then
 			if [[ ! -e ${ROOT%/}${line[0]} && ! -e ${D%/}${line[0]} ]] ; then
-				# hmm, refers explicitly to $EPREFIX, but doesn't exist,
+				# hmm, refers explicitly to ${EPREFIX}, but doesn't exist,
 				# if it's in PATH that's wrong in any case
 				if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
 					echo "${fn#${D}}:${line[0]} (explicit EPREFIX but target not found)" \
@@ -76,7 +76,7 @@ install_qa_check_prefix() {
 			fi
 			continue
 		fi
-		# unprefixed shebang, is the script directly in $PATH?
+		# unprefixed shebang, is the script directly in ${PATH}?
 		if [[ ":${PATH}:" == *":${fp}:"* ]] ; then
 			if [[ -e ${EROOT}${line[0]} || -e ${ED}${line[0]} ]] ; then
 				# is it unprefixed, but we can just fix it because a
@@ -90,12 +90,12 @@ install_qa_check_prefix() {
 				sed -i -e '1s:^#! \?'"${line[0]}"':#!'"${EPREFIX}"${line[0]}':' "${rf}"
 				continue
 			else
-				# this is definitely wrong: script in $PATH and invalid shebang
+				# this is definitely wrong: script in ${PATH} and invalid shebang
 				echo "${fn#${D}}:${line[0]} (script ${fn##*/} installed in PATH but interpreter ${line[0]} not found)" \
 					>> "${T}"/non-prefix-shebangs-errs
 			fi
 		else
-			# unprefixed/invalid shebang, but outside $PATH, this may be
+			# unprefixed/invalid shebang, but outside ${PATH}, this may be
 			# intended (e.g. config.guess) so remain silent by default
 			has stricter ${FEATURES} && \
 				eqawarn "invalid shebang in ${fn#${D}}: ${line[0]}"

diff --git a/bin/install-qa-check.d/10executable-issues b/bin/install-qa-check.d/10executable-issues
index c2355ab8f..837a8be81 100644
--- a/bin/install-qa-check.d/10executable-issues
+++ b/bin/install-qa-check.d/10executable-issues
@@ -20,7 +20,7 @@ elf_check() {
 	#      temporary directory.
 	#   2) If ROOT != "/", references to ROOT are banned because
 	#      that directory won't exist on the target system.
-	#   3) Null paths are banned because the loader will search $PWD when
+	#   3) Null paths are banned because the loader will search ${PWD} when
 	#      it finds null paths.
 	local forbidden_dirs=( "${PORTAGE_BUILDDIR}" )
 	if [[ "${ROOT:-/}" != "/" ]]; then

diff --git a/bin/install-qa-check.d/20deprecated-directories b/bin/install-qa-check.d/20deprecated-directories
index fb82bfe7a..75771a50f 100644
--- a/bin/install-qa-check.d/20deprecated-directories
+++ b/bin/install-qa-check.d/20deprecated-directories
@@ -3,12 +3,12 @@
 deprecated_dir_check() {
 	local x f=
 	for x in etc/app-defaults usr/man usr/info usr/X11R6 usr/doc usr/locale ; do
-		[[ -d ${ED}/$x ]] && f+="  $x\n"
+		[[ -d ${ED}/${x} ]] && f+="  ${x}\n"
 	done
-	if [[ -n $f ]] ; then
+	if [[ -n ${f} ]] ; then
 		eqawarn "QA Notice: This ebuild installs into the following deprecated directories:"
 		eqawarn
-		eqawarn "$f"
+		eqawarn "${f}"
 	fi
 }
 

diff --git a/bin/install-qa-check.d/60udev b/bin/install-qa-check.d/60udev
index c48d7d598..9df18da60 100644
--- a/bin/install-qa-check.d/60udev
+++ b/bin/install-qa-check.d/60udev
@@ -8,10 +8,11 @@ udev_check() {
 		[[ ${x} == ${ED%/}/lib/udev/rules.d/* ]] && continue
 		f+="  ${x#${ED%/}}\n"
 	done
-	if [[ -n $f ]] ; then
+
+	if [[ -n ${f} ]] ; then
 		eqawarn "QA Notice: udev rules should be installed in /lib/udev/rules.d:"
 		eqawarn
-		eqawarn "$f"
+		eqawarn "${f}"
 	fi
 }
 

diff --git a/bin/install-qa-check.d/80libraries b/bin/install-qa-check.d/80libraries
index 81c926982..9855060aa 100644
--- a/bin/install-qa-check.d/80libraries
+++ b/bin/install-qa-check.d/80libraries
@@ -166,7 +166,7 @@ lib_check() {
 		die "static archives (*.a) and libtool library files (*.la) belong in /usr/lib*, not /lib*"
 	fi
 
-	# Verify that the libtool files don't contain bogus $D entries.
+	# Verify that the libtool files don't contain bogus ${D} entries.
 	local abort=no gentoo_bug=no always_overflow=no
 	for a in "${ED%/}"/usr/lib*/*.la ; do
 		s=${a##*/}

diff --git a/bin/install-qa-check.d/90bad-bin-owner b/bin/install-qa-check.d/90bad-bin-owner
index c3ee30746..46d4e3947 100644
--- a/bin/install-qa-check.d/90bad-bin-owner
+++ b/bin/install-qa-check.d/90bad-bin-owner
@@ -25,7 +25,7 @@ bad_bin_owner_check() {
 		# We do want to list non-superuser setuid executables, because
 		# they can be exploited. The owner can simply wipe the setuid
 		# bit, and then alter the contents of the file. The superuser
-		# will then have a time bomb in his $PATH.
+		# will then have a time bomb in his ${PATH}.
 		while read -r -d '' f; do
 			found+=( "${f}" )
 		done < <(find -L "${d}"   \

diff --git a/bin/install-qa-check.d/90gcc-warnings b/bin/install-qa-check.d/90gcc-warnings
index bde198c97..041e39c8b 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -12,6 +12,7 @@ gcc_warn_check() {
 			set +x
 			reset_debug=1
 		fi
+
 		local m msgs=(
 			# only will and does, no might :)
 			'warning: .*will.*\[-Wstrict-aliasing\]'
@@ -79,9 +80,9 @@ gcc_warn_check() {
 
 		local abort="no"
 		local grep_cmd=grep
-		[[ $PORTAGE_LOG_FILE = *.gz ]] && grep_cmd=zgrep
+		[[ ${PORTAGE_LOG_FILE} = *.gz ]] && grep_cmd=zgrep
 
-		# Force C locale to work around slow multibyte locales. #160234
+		# Force C locale to work around slow multibyte locales, bug #160234
 		# Force text mode as newer grep will treat non-ASCII (e.g. UTF-8) as
 		# binary when we run in the C locale.
 		f=$(LC_CTYPE=C LC_COLLATE=C "${grep_cmd}" -E -a "${joined_msgs}" "${PORTAGE_LOG_FILE}" | uniq)
@@ -91,7 +92,8 @@ gcc_warn_check() {
 			#if [[ ${f} == *'will always overflow destination buffer'* ]]; then
 			#	always_overflow=yes
 			#fi
-			if [[ $always_overflow = yes ]] ; then
+
+			if [[ ${always_overflow} = yes ]] ; then
 				eerror
 				eerror "QA Notice: Package triggers severe warnings which indicate that it"
 				eerror "           may exhibit random runtime failures."
@@ -149,7 +151,7 @@ gcc_warn_check() {
 
 		fi
 		if [[ ${abort} == "yes" ]] ; then
-			if [[ $gentoo_bug = yes || $always_overflow = yes ]] ; then
+			if [[ ${gentoo_bug} = yes || ${always_overflow} = yes ]] ; then
 				die "install aborted due to severe warnings shown above"
 			else
 				echo "Please do not file a Gentoo bug and instead" \

diff --git a/bin/install-qa-check.d/90world-writable b/bin/install-qa-check.d/90world-writable
index c69c43444..6a521b3cc 100644
--- a/bin/install-qa-check.d/90world-writable
+++ b/bin/install-qa-check.d/90world-writable
@@ -5,17 +5,17 @@ world_writable_check() {
 	local unsafe_files=$(find "${ED}" -type f -perm -2 | sed -e "s:^${D}:/:")
 	local OLDIFS x prev_shopts=$-
 
-	OLDIFS=$IFS
+	OLDIFS=${IFS}
 	IFS=$'\n'
 	set -f
 
 	if [[ -n ${unsafe_files} ]] ; then
 		eqawarn "QA Security Notice: world writable file(s):"
 
-		eqatag -v world-writable $unsafe_files
+		eqatag -v world-writable ${unsafe_files}
 
 		eqawarn "This may or may not be a security problem, most of the time it is one."
-		eqawarn "Please double check that $PF really needs a world writeable bit and file bugs accordingly."
+		eqawarn "Please double check that ${PF} really needs a world writeable bit and file bugs accordingly."
 		eqawarn
 	fi
 
@@ -23,12 +23,12 @@ world_writable_check() {
 	if [[ -n ${unsafe_files} ]] ; then
 		eqawarn "QA Notice: Unsafe files detected (set*id and world writable)"
 
-		eqatag -v world-writable-setid $unsafe_files
+		eqatag -v world-writable-setid ${unsafe_files}
 
 		die "Unsafe files found in \${D}.  Portage will not install them."
 	fi
 
-	IFS=$OLDIFS
+	IFS=${OLDIFS}
 	[[ ${prev_shopts} == *f* ]] || set +f
 }
 

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 2ec677c69..4542c6715 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -14,8 +14,8 @@ shopt -s expand_aliases
 
 assert() {
 	local x pipestatus=${PIPESTATUS[*]}
-	for x in $pipestatus ; do
-		[[ $x -eq 0 ]] || die "$@"
+	for x in ${pipestatus} ; do
+		[[ ${x} -eq 0 ]] || die "$@"
 	done
 }
 
@@ -36,13 +36,13 @@ __assert_sigpipe_ok() {
 	# as the exit status."
 
 	local x pipestatus=${PIPESTATUS[*]}
-	for x in $pipestatus ; do
+	for x in ${pipestatus} ; do
 		# Allow SIGPIPE through (128 + 13)
-		[[ $x -ne 0 && $x -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
+		[[ ${x} -ne 0 && ${x} -ne ${PORTAGE_SIGPIPE_STATUS:-141} ]] && die "$@"
 	done
 
 	# Require normal success for the last process (tar).
-	[[ $x -eq 0 ]] || die "$@"
+	[[ ${x} -eq 0 ]] || die "$@"
 }
 
 shopt -s extdebug
@@ -91,10 +91,10 @@ __dump_trace() {
 
 nonfatal() {
 	if ! ___eapi_has_nonfatal; then
-		die "$FUNCNAME() not supported in this EAPI"
+		die "${FUNCNAME}() not supported in this EAPI"
 	fi
 	if [[ $# -lt 1 ]]; then
-		die "$FUNCNAME(): Missing argument"
+		die "${FUNCNAME}(): Missing argument"
 	fi
 
 	PORTAGE_NONFATAL=1 "$@"
@@ -157,14 +157,14 @@ die() {
 	# When a helper binary dies automatically in EAPI 4 and later, we don't
 	# get a stack trace, so at least report the phase that failed.
 	local phase_str=
-	[[ -n $EBUILD_PHASE ]] && phase_str=" ($EBUILD_PHASE phase)"
+	[[ -n ${EBUILD_PHASE} ]] && phase_str=" (${EBUILD_PHASE} phase)"
 	eerror "ERROR: ${CATEGORY}/${PF}::${PORTAGE_REPO_NAME} failed${phase_str}:"
 	eerror "  ${*:-(no error message)}"
 	eerror
 	# __dump_trace is useless when the main script is a helper binary
 	local main_index
 	(( main_index = ${#BASH_SOURCE[@]} - 1 ))
-	if has ${BASH_SOURCE[$main_index]##*/} ebuild.sh misc-functions.sh ; then
+	if has ${BASH_SOURCE[${main_index}]##*/} ebuild.sh misc-functions.sh ; then
 	__dump_trace 2 ${filespacing} ${linespacing}
 	eerror "  $(printf "%${filespacing}s" "${BASH_SOURCE[1]##*/}"), line $(printf "%${linespacing}s" "${BASH_LINENO[0]}"):  Called die"
 	eerror "The specific snippet of code:"
@@ -198,13 +198,13 @@ die() {
 	# misc-functions.sh, since those are the only cases where the environment
 	# contains the hook functions. When necessary (like for __helpers_die), die
 	# hooks are automatically called later by a misc-functions.sh invocation.
-	if has ${BASH_SOURCE[$main_index]##*/} ebuild.sh misc-functions.sh && \
+	if has ${BASH_SOURCE[${main_index}]##*/} ebuild.sh misc-functions.sh && \
 		[[ ${EBUILD_PHASE} != depend ]] ; then
 		local x
-		for x in $EBUILD_DEATH_HOOKS; do
+		for x in ${EBUILD_DEATH_HOOKS}; do
 			${x} "$@" >&2 1>&2
 		done
-		> "$PORTAGE_BUILDDIR/.die_hooks"
+		> "${PORTAGE_BUILDDIR}/.die_hooks"
 	fi
 
 	if [[ -n ${PORTAGE_LOG_FILE} ]] ; then
@@ -229,8 +229,8 @@ die() {
 	eerror "Working directory: '$(pwd)'"
 	[[ -n ${S} ]] && eerror "S: '${S}'"
 
-	[[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
-	[[ -n $PORTAGE_IPC_DAEMON ]] && "$PORTAGE_BIN_PATH"/ebuild-ipc exit 1
+	[[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
+	[[ -n ${PORTAGE_IPC_DAEMON} ]] && "${PORTAGE_BIN_PATH}"/ebuild-ipc exit 1
 
 	# subshell die support
 	if [[ -n ${EBUILD_MASTER_PID} && ${BASHPID:-$(__bashpid)} != ${EBUILD_MASTER_PID} ]] ; then
@@ -262,7 +262,7 @@ __elog_base() {
 			;;
 	esac
 	echo -e "$@" | while read -r ; do
-		echo "$messagetype $REPLY" >> \
+		echo "${messagetype} ${REPLY}" >> \
 			"${T}/logging/${EBUILD_PHASE:-other}"
 	done
 	return 0
@@ -398,18 +398,20 @@ __unset_colors() {
 }
 
 __set_colors() {
-	COLS=${COLUMNS:-0}      # bash's internal COLUMNS variable
+	# bash's internal COLUMNS variable
+	COLS=${COLUMNS:-0}
+
 	# Avoid wasteful stty calls during the "depend" phases.
 	# If stdout is a pipe, the parent process can export COLUMNS
 	# if it's relevant. Use an extra subshell for stty calls, in
 	# order to redirect "/dev/tty: No such device or address"
 	# error from bash to /dev/null.
-	[[ $COLS == 0 && $EBUILD_PHASE != depend ]] && \
+	[[ ${COLS} == 0 && ${EBUILD_PHASE} != depend ]] && \
 		COLS=$(set -- $( ( stty size </dev/tty ) 2>/dev/null || echo 24 80 ) ; echo $2)
 	(( COLS > 0 )) || (( COLS = 80 ))
 
 	# Now, ${ENDCOL} will move us to the end of the
-	# column;  irregardless of character width
+	# column; regardless of character width
 	ENDCOL=$'\e[A\e['$(( COLS - 8 ))'C'
 	if [[ -n "${PORTAGE_COLORMAP}" ]]; then
 		eval ${PORTAGE_COLORMAP}
@@ -617,7 +619,7 @@ else
 fi
 
 # debug-print() gets called from many places with verbose status information useful
-# for tracking down problems. The output is in $T/eclass-debug.log.
+# for tracking down problems. The output is in ${T}/eclass-debug.log.
 # You can set ECLASS_DEBUG_OUTPUT to redirect the output somewhere else as well.
 # The special "on" setting echoes the information, mixing it with the rest of the
 # emerge output.
@@ -626,9 +628,9 @@ fi
 #
 # (TODO: in the future, might use e* from /lib/gentoo/functions.sh?)
 debug-print() {
-	# if $T isn't defined, we're in dep calculation mode and
+	# If ${T} isn't defined, we're in dep calculation mode and
 	# shouldn't do anything
-	[[ $EBUILD_PHASE = depend || ! -d ${T} || ${#} -eq 0 ]] && return 0
+	[[ ${EBUILD_PHASE} = depend || ! -d ${T} || ${#} -eq 0 ]] && return 0
 
 	if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then
 		printf 'debug: %s\n' "${@}" >&2
@@ -636,10 +638,11 @@ debug-print() {
 		printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}"
 	fi
 
-	if [[ -w $T ]] ; then
-		# default target
+	if [[ -w ${T} ]] ; then
+		# Default target
 		printf '%s\n' "${@}" >> "${T}/eclass-debug.log"
-		# let the portage user own/write to this file
+
+		# Let the portage user own/write to this file
 		chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/eclass-debug.log"
 		chmod g+w "${T}/eclass-debug.log"
 	fi

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 466d21dfd..faa8184c6 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -135,7 +135,7 @@ install_qa_check() {
 		)
 	done < <(printf "%s\0" "${qa_checks[@]}" | LC_ALL=C sort -u -z)
 
-	if has chflags $FEATURES ; then
+	if has chflags ${FEATURES} ; then
 		# Save all the file flags for restoration afterwards.
 		mtree -c -p "${ED}" -k flags > "${T}/bsdflags.mtree"
 		# Remove all the file flags so that we can do anything necessary.
@@ -153,7 +153,7 @@ install_qa_check() {
 		"${PORTAGE_BIN_PATH}"/ecompress --dequeue
 	fi
 
-	if has chflags $FEATURES ; then
+	if has chflags ${FEATURES} ; then
 		# Restore all the file flags that were saved earlier on.
 		mtree -U -e -p "${ED}" -k flags < "${T}/bsdflags.mtree" &> /dev/null
 	fi
@@ -164,7 +164,7 @@ install_qa_check() {
 	# containing pre-built binaries.
 	if type -P scanelf > /dev/null ; then
 		# Save NEEDED information after removing self-contained providers
-		rm -f "$PORTAGE_BUILDDIR"/build-info/NEEDED{,.ELF.2}
+		rm -f "${PORTAGE_BUILDDIR}"/build-info/NEEDED{,.ELF.2}
 
 		# We don't use scanelf -q, since that would omit libraries like
 		# musl's /usr/lib/libc.so which do not have any DT_NEEDED or
@@ -258,7 +258,7 @@ install_qa_check() {
 
 __dyn_instprep() {
 	if [[ -e ${PORTAGE_BUILDDIR}/.instprepped ]] ; then
-		__vecho ">>> It appears that '$PF' is already instprepped; skipping."
+		__vecho ">>> It appears that '${PF}' is already instprepped; skipping."
 		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.instprepped' to force instprep."
 		return 0
 	fi
@@ -396,29 +396,29 @@ preinst_sfperms() {
 	fi
 
 	# Smart FileSystem Permissions
-	if has sfperms $FEATURES; then
+	if has sfperms ${FEATURES}; then
 		local i
 		find "${ED}" -type f -perm -4000 -print0 | \
 		while read -r -d $'\0' i ; do
-			if [[ -n "$(find "$i" -perm -2000)" ]]; then
+			if [[ -n "$(find "${i}" -perm -2000)" ]]; then
 				ebegin ">>> SetUID and SetGID: [chmod o-r] ${i#${ED%/}}"
-				chmod o-r "$i"
+				chmod o-r "${i}"
 				eend $?
 			else
 				ebegin ">>> SetUID: [chmod go-r] ${i#${ED%/}}"
-				chmod go-r "$i"
+				chmod go-r "${i}"
 				eend $?
 			fi
 		done
 		find "${ED}" -type f -perm -2000 -print0 | \
 		while read -r -d $'\0' i ; do
-			if [[ -n "$(find "$i" -perm -4000)" ]]; then
+			if [[ -n "$(find "${i}" -perm -4000)" ]]; then
 				# This case is already handled
 				# by the SetUID check above.
 				true
 			else
 				ebegin ">>> SetGID: [chmod o-r] ${i#${ED%/}}"
-				chmod o-r "$i"
+				chmod o-r "${i}"
 				eend $?
 			fi
 		done
@@ -436,7 +436,7 @@ preinst_suid_scan() {
 	fi
 
 	# Total suid control
-	if has suidctl $FEATURES; then
+	if has suidctl ${FEATURES}; then
 		local i sfconf x
 		sfconf=${PORTAGE_CONFIGROOT}etc/portage/suidctl.conf
 		# sandbox prevents us from writing directly
@@ -497,17 +497,16 @@ preinst_selinux_labels() {
 }
 
 __dyn_package() {
-
 	if ! ___eapi_has_prefix_variables; then
 		local EPREFIX=
 	fi
 
-	# Make sure $PWD is not ${D} so that we don't leave gmon.out files
+	# Make sure ${PWD} is not ${D} so that we don't leave gmon.out files
 	# in there in case any tools were built with -pg in CFLAGS.
 	cd "${T}" || die
 
 	# Sandbox is disabled in case the user wants to use a symlink
-	# for $PKGDIR and/or $PKGDIR/All.
+	# for ${PKGDIR} and/or ${PKGDIR}/All.
 	export SANDBOX_ON="0"
 	[[ -z "${PORTAGE_BINPKG_TMPFILE}" ]] && \
 		die "PORTAGE_BINPKG_TMPFILE is unset"
@@ -515,20 +514,24 @@ __dyn_package() {
 
 	if [[ "${BINPKG_FORMAT}" == "xpak" ]]; then
 		local tar_options=""
-		[[ $PORTAGE_VERBOSE = 1 ]] && tar_options+=" -v"
+
+		[[ ${PORTAGE_VERBOSE} = 1 ]] && tar_options+=" -v"
 		has xattr ${FEATURES} && [[ $(tar --help 2> /dev/null) == *--xattrs* ]] && tar_options+=" --xattrs"
-		[[ -z "${PORTAGE_COMPRESSION_COMMAND}" ]] && \
-			die "PORTAGE_COMPRESSION_COMMAND is unset"
-		tar $tar_options -cf - $PORTAGE_BINPKG_TAR_OPTS -C "${D}" . | \
-			$PORTAGE_COMPRESSION_COMMAND > "$PORTAGE_BINPKG_TMPFILE"
-		assert "failed to pack binary package: '$PORTAGE_BINPKG_TMPFILE'"
+
+		[[ -z "${PORTAGE_COMPRESSION_COMMAND}" ]] && die "PORTAGE_COMPRESSION_COMMAND is unset"
+
+		tar ${tar_options} -cf - ${PORTAGE_BINPKG_TAR_OPTS} -C "${D}" . | \
+			${PORTAGE_COMPRESSION_COMMAND} > "${PORTAGE_BINPKG_TMPFILE}"
+		assert "failed to pack binary package: '${PORTAGE_BINPKG_TMPFILE}'"
+
 		PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-			"${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH"/xpak-helper.py recompose \
-			"$PORTAGE_BINPKG_TMPFILE" "$PORTAGE_BUILDDIR/build-info"
+			"${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}"/xpak-helper.py recompose \
+			"${PORTAGE_BINPKG_TMPFILE}" "${PORTAGE_BUILDDIR}/build-info"
 		if [[ $? -ne 0 ]]; then
 			rm -f "${PORTAGE_BINPKG_TMPFILE}"
 			die "Failed to append metadata to the tbz2 file"
 		fi
+
 		local md5_hash=""
 		if type md5sum &>/dev/null ; then
 			md5_hash=$(md5sum "${PORTAGE_BINPKG_TMPFILE}")
@@ -537,14 +540,14 @@ __dyn_package() {
 			md5_hash=$(md5 "${PORTAGE_BINPKG_TMPFILE}")
 			md5_hash=${md5_hash##* }
 		fi
-		[[ -n "${md5_hash}" ]] && \
-			echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
+
+		[[ -n "${md5_hash}" ]] && echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
 		__vecho ">>> Done."
 
 	elif [[ "${BINPKG_FORMAT}" == "gpkg" ]]; then
 		PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \
-			"${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH"/gpkg-helper.py compress \
-			"${CATEGORY}/${PF}" "$PORTAGE_BINPKG_TMPFILE" "$PORTAGE_BUILDDIR/build-info" "${D}"
+			"${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}"/gpkg-helper.py compress \
+			"${CATEGORY}/${PF}" "${PORTAGE_BINPKG_TMPFILE}" "${PORTAGE_BUILDDIR}/build-info" "${D}"
 		if [[ $? -ne 0 ]]; then
 			rm -f "${PORTAGE_BINPKG_TMPFILE}"
 			die "Failed to create binpkg file"
@@ -555,8 +558,7 @@ __dyn_package() {
 	fi
 
 	cd "${PORTAGE_BUILDDIR}"
-	>> "$PORTAGE_BUILDDIR/.packaged" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.packaged"
+	>> "${PORTAGE_BUILDDIR}/.packaged" || die "Failed to create ${PORTAGE_BUILDDIR}/.packaged"
 }
 
 __dyn_spec() {
@@ -602,30 +604,35 @@ __dyn_rpm() {
 	fi
 
 	cd "${T}" || die "cd failed"
+
 	local machine_name=${CHOST%%-*}
 	local dest_dir=${T}/rpmbuild/RPMS/${machine_name}
+
 	addwrite "${RPMDIR}"
 	__dyn_spec
 	HOME=${T} \
 	rpmbuild -bb --clean --nodeps --rmsource "${PF}.spec" --buildroot "${D}" --target "${CHOST}" || die "Failed to integrate rpm spec file"
+
 	install -D "${dest_dir}/${PN}-${PV}-${PR}.${machine_name}.rpm" \
 		"${RPMDIR}/${CATEGORY}/${PN}-${PV}-${PR}.rpm" || \
 		die "Failed to move rpm"
 }
 
 die_hooks() {
-	[[ -f $PORTAGE_BUILDDIR/.die_hooks ]] && return
+	[[ -f ${PORTAGE_BUILDDIR}/.die_hooks ]] && return
+
 	local x
-	for x in $EBUILD_DEATH_HOOKS ; do
-		$x >&2
+	for x in ${EBUILD_DEATH_HOOKS} ; do
+		${x} >&2
 	done
-	> "$PORTAGE_BUILDDIR/.die_hooks"
+
+	> "${PORTAGE_BUILDDIR}/.die_hooks"
 }
 
 success_hooks() {
 	local x
-	for x in $EBUILD_SUCCESS_HOOKS ; do
-		$x
+	for x in ${EBUILD_SUCCESS_HOOKS} ; do
+		${x}
 	done
 }
 
@@ -633,15 +640,17 @@ install_hooks() {
 	local hooks_dir="${PORTAGE_CONFIGROOT}etc/portage/hooks/install"
 	local fp
 	local ret=0
+
 	shopt -s nullglob
 	for fp in "${hooks_dir}"/*; do
-		if [[ -x "$fp" ]]; then
-			"$fp"
-			ret=$(( $ret | $? ))
+		if [[ -x "${fp}" ]]; then
+			"${fp}"
+			ret=$(( ${ret} | $? ))
 		fi
 	done
 	shopt -u nullglob
-	return $ret
+
+	return ${ret}
 }
 
 eqatag() {
@@ -650,15 +659,19 @@ eqatag() {
 
 if [[ -n "${MISC_FUNCTIONS_ARGS}" ]]; then
 	__source_all_bashrcs
-	[[ "$PORTAGE_DEBUG" == "1" ]] && set -x
+
+	[[ "${PORTAGE_DEBUG}" == "1" ]] && set -x
+
 	for x in ${MISC_FUNCTIONS_ARGS}; do
 		${x}
 	done
 	unset x
-	[[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
-	if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
-		[[ ! -s $SANDBOX_LOG ]]
-		"$PORTAGE_BIN_PATH"/ebuild-ipc exit $?
+
+	[[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
+
+	if [[ -n ${PORTAGE_IPC_DAEMON} ]] ; then
+		[[ ! -s ${SANDBOX_LOG} ]]
+		"${PORTAGE_BIN_PATH}"/ebuild-ipc exit $?
 	fi
 fi
 

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index f615ba491..687e1ab03 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -97,8 +97,8 @@ __filter_readonly_variables() {
 	# Untrusted due to possible application of package renames to binpkgs
 	local binpkg_untrusted_vars="CATEGORY P PF PN PR PV PVR"
 	local misc_garbage_vars="_portage_filter_opts"
-	filtered_vars="___.* $readonly_bash_vars $bash_misc_vars
-		$PORTAGE_READONLY_VARS $misc_garbage_vars"
+	filtered_vars="___.* ${readonly_bash_vars} ${bash_misc_vars}
+		${PORTAGE_READONLY_VARS} ${misc_garbage_vars}"
 
 	# Filter SYSROOT unconditionally. It is propagated in every EAPI
 	# because it was used unofficially before EAPI 7. See bug #661006.
@@ -165,11 +165,13 @@ __preprocess_ebuild_env() {
 	# Otherwise, we don't need to filter the environment.
 	[[ -f "${T}/environment.raw" ]] || return 0
 
-	__filter_readonly_variables $_portage_filter_opts < "${T}"/environment \
-		>> "$T/environment.filtered" || return $?
+	__filter_readonly_variables ${_portage_filter_opts} < "${T}"/environment \
+		>> "${T}/environment.filtered" || return $?
+
 	unset _portage_filter_opts
 	mv "${T}"/environment.filtered "${T}"/environment || return $?
 	rm -f "${T}/environment.success" || return $?
+
 	# WARNING: Code inside this subshell should avoid making assumptions
 	# about variables or functions after source "${T}"/environment has been
 	# called. Any variables that need to be relied upon should already be
@@ -192,8 +194,9 @@ __preprocess_ebuild_env() {
 		# Rely on __save_ebuild_env() to filter out any remaining variables
 		# and functions that could interfere with the current environment.
 		__save_ebuild_env || exit $?
-		>> "$T/environment.success" || exit $?
+		>> "${T}/environment.success" || exit $?
 	) > "${T}/environment.filtered"
+
 	local retval
 	if [[ -e "${T}/environment.success" ]]; then
 		__filter_readonly_variables --filter-features < \
@@ -202,12 +205,14 @@ __preprocess_ebuild_env() {
 	else
 		retval=1
 	fi
+
 	rm -f "${T}"/environment.{filtered,raw,success}
 	return ${retval}
 }
 
 __ebuild_phase() {
 	local __EBEGIN_EEND_COUNT=0
+
 	declare -F "$1" >/dev/null && __qa_call $1
 	if (( __EBEGIN_EEND_COUNT > 0 )); then
 		eqawarn "QA Notice: ebegin called without eend in $1"
@@ -222,28 +227,30 @@ __ebuild_phase_with_hooks() {
 }
 
 __dyn_pretend() {
-	if [[ -e $PORTAGE_BUILDDIR/.pretended ]] ; then
-		__vecho ">>> It appears that '$PF' is already pretended; skipping."
-		__vecho ">>> Remove '$PORTAGE_BUILDDIR/.pretended' to force pretend."
+	if [[ -e ${PORTAGE_BUILDDIR}/.pretended ]] ; then
+		__vecho ">>> It appears that '${PF}' is already pretended; skipping."
+		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.pretended' to force pretend."
 		return 0
 	fi
+
 	__ebuild_phase pre_pkg_pretend
 	__ebuild_phase pkg_pretend
-	>> "$PORTAGE_BUILDDIR/.pretended" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.pretended"
+	>> "${PORTAGE_BUILDDIR}/.pretended" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.pretended"
 	__ebuild_phase post_pkg_pretend
 }
 
 __dyn_setup() {
-	if [[ -e $PORTAGE_BUILDDIR/.setuped ]] ; then
-		__vecho ">>> It appears that '$PF' is already setup; skipping."
-		__vecho ">>> Remove '$PORTAGE_BUILDDIR/.setuped' to force setup."
+	if [[ -e ${PORTAGE_BUILDDIR}/.setuped ]] ; then
+		__vecho ">>> It appears that '${PF}' is already setup; skipping."
+		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.setuped' to force setup."
 		return 0
 	fi
+
 	__ebuild_phase pre_pkg_setup
 	__ebuild_phase pkg_setup
-	>> "$PORTAGE_BUILDDIR/.setuped" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.setuped"
+	>> "${PORTAGE_BUILDDIR}/.setuped" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.setuped"
 	__ebuild_phase post_pkg_setup
 }
 
@@ -252,15 +259,17 @@ __dyn_unpack() {
 		__vecho ">>> WORKDIR is up-to-date, keeping..."
 		return 0
 	fi
+
 	if [[ ! -d "${WORKDIR}" ]]; then
 		install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
 	fi
+
 	cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
 	__ebuild_phase pre_src_unpack
 	__vecho ">>> Unpacking source..."
 	__ebuild_phase src_unpack
-	>> "$PORTAGE_BUILDDIR/.unpacked" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.unpacked"
+	>> "${PORTAGE_BUILDDIR}/.unpacked" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.unpacked"
 	__vecho ">>> Source unpacked in ${WORKDIR}"
 	__ebuild_phase post_src_unpack
 }
@@ -272,7 +281,8 @@ __dyn_clean() {
 	elif [[ ! -d "${PORTAGE_BUILDDIR}" ]]; then
 		return 0
 	fi
-	if has chflags $FEATURES ; then
+
+	if has chflags ${FEATURES} ; then
 		chflags -R noschg,nouchg,nosappnd,nouappnd "${PORTAGE_BUILDDIR}"
 		chflags -R nosunlnk,nouunlnk "${PORTAGE_BUILDDIR}" 2>/dev/null
 	fi
@@ -286,16 +296,16 @@ __dyn_clean() {
 		"${PORTAGE_BUILDDIR}/empty"
 	rm -f "${PORTAGE_BUILDDIR}/.installed"
 
-	if [[ $EMERGE_FROM = binary ]] || \
-		! has keeptemp $FEATURES && ! has keepwork $FEATURES ; then
+	if [[ ${EMERGE_FROM} = binary ]] || \
+		! has keeptemp ${FEATURES} && ! has keepwork ${FEATURES} ; then
 		rm -rf "${T}"
 	fi
 
-	if [[ $EMERGE_FROM = binary ]] || ! has keepwork $FEATURES; then
-		rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,logid,pretended,setuped,unpacked,prepared} \
-			"$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged,instprepped} \
-			"$PORTAGE_BUILDDIR"/.die_hooks \
-			"$PORTAGE_BUILDDIR"/.exit_status
+	if [[ ${EMERGE_FROM} = binary ]] || ! has keepwork ${FEATURES} ; then
+		rm -f "${PORTAGE_BUILDDIR}"/.{ebuild_changed,logid,pretended,setuped,unpacked,prepared} \
+			"${PORTAGE_BUILDDIR}"/.{configured,compiled,tested,packaged,instprepped} \
+			"${PORTAGE_BUILDDIR}"/.die_hooks \
+			"${PORTAGE_BUILDDIR}"/.exit_status
 
 		rm -rf "${PORTAGE_BUILDDIR}/build-info" \
 			"${PORTAGE_BUILDDIR}/.ipc"
@@ -304,14 +314,14 @@ __dyn_clean() {
 	fi
 
 	if [[ -f "${PORTAGE_BUILDDIR}/.unpacked" ]]; then
-		find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | sort -r | tr "\n" "\0" | $XARGS -0 rmdir &>/dev/null
+		find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | sort -r | tr "\n" "\0" | ${XARGS} -0 rmdir &>/dev/null
 	fi
 
-	# do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll
+	# Do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll
 	# result in it wiping the users distfiles directory (bad).
 	rm -rf "${PORTAGE_BUILDDIR}/distdir"
 
-	rmdir "$PORTAGE_BUILDDIR" 2>/dev/null
+	rmdir "${PORTAGE_BUILDDIR}" 2>/dev/null
 
 	true
 }
@@ -324,22 +334,23 @@ __abort_handler() {
 		msg="${EBUILD}: ${1} failed; exiting."
 	fi
 	echo
-	echo "$msg"
+	echo "${msg}"
 	echo
 	eval ${3}
-	#unset signal handler
+
+	# Unset signal handler
 	trap - SIGINT SIGQUIT
 }
 
 __abort_prepare() {
 	__abort_handler src_prepare $1
-	rm -f "$PORTAGE_BUILDDIR/.prepared"
+	rm -f "${PORTAGE_BUILDDIR}/.prepared"
 	exit 1
 }
 
 __abort_configure() {
 	__abort_handler src_configure $1
-	rm -f "$PORTAGE_BUILDDIR/.configured"
+	rm -f "${PORTAGE_BUILDDIR}/.configured"
 	exit 1
 }
 
@@ -373,13 +384,13 @@ __has_phase_defined_up_to() {
 
 __dyn_prepare() {
 
-	if [[ -e $PORTAGE_BUILDDIR/.prepared ]] ; then
-		__vecho ">>> It appears that '$PF' is already prepared; skipping."
-		__vecho ">>> Remove '$PORTAGE_BUILDDIR/.prepared' to force prepare."
+	if [[ -e ${PORTAGE_BUILDDIR}/.prepared ]] ; then
+		__vecho ">>> It appears that '${PF}' is already prepared; skipping."
+		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.prepared' to force prepare."
 		return 0
 	fi
 
-	if [[ -d $S ]] ; then
+	if [[ -d ${S} ]] ; then
 		cd "${S}"
 	elif ___eapi_has_S_WORKDIR_fallback; then
 		cd "${WORKDIR}"
@@ -392,7 +403,7 @@ __dyn_prepare() {
 	trap __abort_prepare SIGINT SIGQUIT
 
 	__ebuild_phase pre_src_prepare
-	__vecho ">>> Preparing source in $PWD ..."
+	__vecho ">>> Preparing source in ${PWD} ..."
 	__ebuild_phase src_prepare
 
 	# keep path in eapply_user in sync!
@@ -400,8 +411,8 @@ __dyn_prepare() {
 		die "eapply_user (or default) must be called in src_prepare()!"
 	fi
 
-	>> "$PORTAGE_BUILDDIR/.prepared" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.prepared"
+	>> "${PORTAGE_BUILDDIR}/.prepared" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.prepared"
 	__vecho ">>> Source prepared."
 	__ebuild_phase post_src_prepare
 
@@ -409,14 +420,13 @@ __dyn_prepare() {
 }
 
 __dyn_configure() {
-
-	if [[ -e $PORTAGE_BUILDDIR/.configured ]] ; then
-		__vecho ">>> It appears that '$PF' is already configured; skipping."
-		__vecho ">>> Remove '$PORTAGE_BUILDDIR/.configured' to force configuration."
+	if [[ -e ${PORTAGE_BUILDDIR}/.configured ]] ; then
+		__vecho ">>> It appears that '${PF}' is already configured; skipping."
+		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.configured' to force configuration."
 		return 0
 	fi
 
-	if [[ -d $S ]] ; then
+	if [[ -d ${S} ]] ; then
 		cd "${S}"
 	elif ___eapi_has_S_WORKDIR_fallback; then
 		cd "${WORKDIR}"
@@ -430,10 +440,10 @@ __dyn_configure() {
 
 	__ebuild_phase pre_src_configure
 
-	__vecho ">>> Configuring source in $PWD ..."
+	__vecho ">>> Configuring source in ${PWD} ..."
 	__ebuild_phase src_configure
-	>> "$PORTAGE_BUILDDIR/.configured" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.configured"
+	>> "${PORTAGE_BUILDDIR}/.configured" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.configured"
 	__vecho ">>> Source configured."
 
 	__ebuild_phase post_src_configure
@@ -442,14 +452,13 @@ __dyn_configure() {
 }
 
 __dyn_compile() {
-
-	if [[ -e $PORTAGE_BUILDDIR/.compiled ]] ; then
+	if [[ -e ${PORTAGE_BUILDDIR}/.compiled ]] ; then
 		__vecho ">>> It appears that '${PF}' is already compiled; skipping."
-		__vecho ">>> Remove '$PORTAGE_BUILDDIR/.compiled' to force compilation."
+		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force compilation."
 		return 0
 	fi
 
-	if [[ -d $S ]] ; then
+	if [[ -d ${S} ]] ; then
 		cd "${S}"
 	elif ___eapi_has_S_WORKDIR_fallback; then
 		cd "${WORKDIR}"
@@ -463,10 +472,10 @@ __dyn_compile() {
 
 	__ebuild_phase pre_src_compile
 
-	__vecho ">>> Compiling source in $PWD ..."
+	__vecho ">>> Compiling source in ${PWD} ..."
 	__ebuild_phase src_compile
-	>> "$PORTAGE_BUILDDIR/.compiled" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.compiled"
+	>> "${PORTAGE_BUILDDIR}/.compiled" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.compiled"
 	__vecho ">>> Source compiled."
 
 	__ebuild_phase post_src_compile
@@ -475,8 +484,7 @@ __dyn_compile() {
 }
 
 __dyn_test() {
-
-	if [[ -e $PORTAGE_BUILDDIR/.tested ]] ; then
+	if [[ -e ${PORTAGE_BUILDDIR}/.tested ]] ; then
 		__vecho ">>> It appears that ${PN} has already been tested; skipping."
 		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.tested' to force test."
 		return
@@ -513,8 +521,8 @@ __dyn_test() {
 		__ebuild_phase src_test
 		__vecho ">>> Completed testing ${CATEGORY}/${PF}"
 
-		>> "$PORTAGE_BUILDDIR/.tested" || \
-			die "Failed to create $PORTAGE_BUILDDIR/.tested"
+		>> "${PORTAGE_BUILDDIR}/.tested" || \
+			die "Failed to create ${PORTAGE_BUILDDIR}/.tested"
 		__ebuild_phase post_src_test
 		SANDBOX_PREDICT=${save_sp}
 	fi
@@ -523,10 +531,11 @@ __dyn_test() {
 }
 
 __dyn_install() {
-	[[ -z "$PORTAGE_BUILDDIR" ]] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
-	if has noauto $FEATURES ; then
+	[[ -z "${PORTAGE_BUILDDIR}" ]] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
+
+	if has noauto ${FEATURES} ; then
 		rm -f "${PORTAGE_BUILDDIR}/.installed"
-	elif [[ -e $PORTAGE_BUILDDIR/.installed ]] ; then
+	elif [[ -e ${PORTAGE_BUILDDIR}/.installed ]] ; then
 		__vecho ">>> It appears that '${PF}' is already installed; skipping."
 		__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.installed' to force install."
 		return 0
@@ -537,16 +546,16 @@ __dyn_install() {
 	# Those variables shouldn't be needed before src_install()
 	# (QA_PRESTRIPPED is used in prepstrip, others in install-qa-checks)
 	# and delay in setting them allows us to set them in pkg_setup()
-	if [[ -n $QA_PREBUILT ]] ; then
-		# these ones support fnmatch patterns
-		QA_EXECSTACK+=" $QA_PREBUILT"
-		QA_TEXTRELS+=" $QA_PREBUILT"
-		QA_WX_LOAD+=" $QA_PREBUILT"
+	if [[ -n ${QA_PREBUILT} ]] ; then
+		# These ones support fnmatch patterns
+		QA_EXECSTACK+=" ${QA_PREBUILT}"
+		QA_TEXTRELS+=" ${QA_PREBUILT}"
+		QA_WX_LOAD+=" ${QA_PREBUILT}"
 
-		# these ones support regular expressions, so translate
+		# These ones support regular expressions, so translate
 		# fnmatch patterns to regular expressions
 		for x in QA_DT_NEEDED QA_FLAGS_IGNORED QA_PRESTRIPPED QA_SONAME ; do
-			if [[ $(declare -p $x 2>/dev/null) = declare\ -a* ]] ; then
+			if [[ $(declare -p ${x} 2>/dev/null) = declare\ -a* ]] ; then
 				eval "${x}=(\"\${${x}[@]}\" ${QA_PREBUILT//\*/.*})"
 			else
 				eval "${x}+=\" ${QA_PREBUILT//\*/.*}\""
@@ -555,9 +564,10 @@ __dyn_install() {
 
 		unset x
 	fi
+
 	# This needs to be exported since prepstrip is a separate shell script.
-	[[ -n $QA_PRESTRIPPED ]] && export QA_PRESTRIPPED
-	eval "[[ -n \$QA_PRESTRIPPED_${ARCH/-/_} ]] && \
+	[[ -n ${QA_PRESTRIPPED} ]] && export QA_PRESTRIPPED
+	eval "[[ -n \${QA_PRESTRIPPED_${ARCH/-/_}} ]] && \
 		export QA_PRESTRIPPED_${ARCH/-/_}"
 
 	__ebuild_phase pre_src_install
@@ -571,7 +581,7 @@ __dyn_install() {
 	mkdir -p "${_x}"
 	unset _x
 
-	if [[ -d $S ]] ; then
+	if [[ -d ${S} ]] ; then
 		cd "${S}"
 	elif ___eapi_has_S_WORKDIR_fallback; then
 		cd "${WORKDIR}"
@@ -583,8 +593,9 @@ __dyn_install() {
 
 	__vecho
 	__vecho ">>> Install ${CATEGORY}/${PF} into ${D}"
-	#our custom version of libtool uses $S and $D to fix
-	#invalid paths in .la files
+
+	# Our custom version of libtool uses ${S} and ${D} to fix
+	# invalid paths in .la files
 	export S D
 
 	# Reset exeinto(), docinto(), insinto(), and into() state variables
@@ -601,8 +612,8 @@ __dyn_install() {
 	export _E_DOCDESTTREE_=""
 
 	__ebuild_phase src_install
-	>> "$PORTAGE_BUILDDIR/.installed" || \
-		die "Failed to create $PORTAGE_BUILDDIR/.installed"
+	>> "${PORTAGE_BUILDDIR}/.installed" || \
+		die "Failed to create ${PORTAGE_BUILDDIR}/.installed"
 	__vecho ">>> Completed installing ${CATEGORY}/${PF} into ${D}"
 	__vecho
 	__ebuild_phase post_src_install
@@ -675,11 +686,11 @@ __dyn_install() {
 		PKG_INSTALL_MASK; do
 
 		x=$(echo -n ${!f})
-		[[ -n $x ]] && echo "$x" > $f
+		[[ -n ${x} ]] && echo "${x}" > ${f}
 	done
 	# whitespace preserved
 	for f in QA_AM_MAINTAINER_MODE ; do
-		[[ -n ${!f} ]] && echo "${!f}" > $f
+		[[ -n ${!f} ]] && echo "${!f}" > ${f}
 	done
 	echo "${USE}"       > USE
 	echo "${EAPI:-0}"   > EAPI
@@ -708,8 +719,7 @@ __dyn_install() {
 
 	cp "${EBUILD}" "${PF}.ebuild"
 	[[ -n "${PORTAGE_REPO_NAME}" ]]  && echo "${PORTAGE_REPO_NAME}" > repository
-	if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}
-	then
+	if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}; then
 		>> DEBUGBUILD
 	fi
 	trap - SIGINT SIGQUIT
@@ -718,7 +728,7 @@ __dyn_install() {
 __dyn_help() {
 	echo
 	echo "Portage"
-	echo "Copyright 1999-2010 Gentoo Foundation"
+	echo "Copyright 1999-2022 Gentoo Authors"
 	echo
 	echo "How to use the ebuild command:"
 	echo
@@ -759,19 +769,18 @@ __dyn_help() {
 	echo "  category    : ${CATEGORY}"
 	echo "  description : ${DESCRIPTION}"
 	echo "  system      : ${CHOST}"
-	echo "  c flags     : ${CFLAGS}"
-	echo "  c++ flags   : ${CXXFLAGS}"
+	echo "  C flags     : ${CFLAGS}"
+	echo "  C++ flags   : ${CXXFLAGS}"
 	echo "  make flags  : ${MAKEOPTS}"
 	echo -n "  build mode  : "
-	if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}
-	then
+	if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip ${PORTAGE_RESTRICT}; then
 		echo "debug (large)"
 	else
 		echo "production (stripped)"
 	fi
 	echo "  merge to    : ${ROOT}"
 	echo
-	if [[ -n "$USE" ]]; then
+	if [[ -n "${USE}" ]]; then
 		echo "Additionally, support for the following optional features will be enabled:"
 		echo
 		echo "  ${USE}"
@@ -788,7 +797,7 @@ __ebuild_arg_to_phase() {
 	local arg=$1
 	local phase_func=""
 
-	case "$arg" in
+	case "${arg}" in
 		pretend)
 			___eapi_has_pkg_pretend && \
 				phase_func=pkg_pretend
@@ -833,13 +842,14 @@ __ebuild_arg_to_phase() {
 			;;
 	esac
 
-	[[ -z $phase_func ]] && return 1
-	echo "$phase_func"
+	[[ -z ${phase_func} ]] && return 1
+	echo "${phase_func}"
 	return 0
 }
 
 __ebuild_phase_funcs() {
 	[[ $# -ne 2 ]] && die "expected exactly 2 args, got $#: $*"
+
 	local eapi=$1
 	local phase_func=$2
 	local all_phases="src_compile pkg_config src_configure pkg_info
@@ -860,16 +870,16 @@ __ebuild_phase_funcs() {
 		default_${phase_func}
 	}"
 
-	case "$eapi" in
+	case "${eapi}" in
 		0|1) # EAPIs not supporting 'default'
 
 			for x in pkg_nofetch src_unpack src_test ; do
-				declare -F $x >/dev/null || \
-					eval "$x() { __eapi0_$x; }"
+				declare -F ${x} >/dev/null || \
+					eval "$x() { __eapi0_${x}; }"
 			done
 
 			if ! declare -F src_compile >/dev/null ; then
-				case "$eapi" in
+				case "${eapi}" in
 					0)
 						src_compile() { __eapi0_src_compile; }
 						;;
@@ -942,43 +952,42 @@ __ebuild_phase_funcs() {
 }
 
 __ebuild_main() {
-
 	# Subshell/helper die support (must export for the die helper).
 	# Since this function is typically executed in a subshell,
-	# setup EBUILD_MASTER_PID to refer to the current $BASHPID,
+	# setup EBUILD_MASTER_PID to refer to the current ${BASHPID},
 	# which seems to give the best results when further
 	# nested subshells call die.
 	export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
 	trap 'exit 1' SIGTERM
 
-	#a reasonable default for $S
+	# A reasonable default for ${S}
 	[[ -z ${S} ]] && export S=${WORKDIR}/${P}
 
-	if [[ -s $SANDBOX_LOG ]] ; then
+	if [[ -s ${SANDBOX_LOG} ]] ; then
 		# We use SANDBOX_LOG to check for sandbox violations,
 		# so we ensure that there can't be a stale log to
 		# interfere with our logic.
 		local x=
-		if [[ -n $SANDBOX_ON ]] ; then
-			x=$SANDBOX_ON
+		if [[ -n ${SANDBOX_ON} ]] ; then
+			x=${SANDBOX_ON}
 			export SANDBOX_ON=0
 		fi
 
-		rm -f "$SANDBOX_LOG" || \
-			die "failed to remove stale sandbox log: '$SANDBOX_LOG'"
+		rm -f "${SANDBOX_LOG}" || \
+			die "failed to remove stale sandbox log: '${SANDBOX_LOG}'"
 
-		if [[ -n $x ]] ; then
-			export SANDBOX_ON=$x
+		if [[ -n ${x} ]] ; then
+			export SANDBOX_ON=${x}
 		fi
 		unset x
 	fi
 
 	# Force configure scripts that automatically detect ccache to
 	# respect FEATURES="-ccache".
-	has ccache $FEATURES || export CCACHE_DISABLE=1
+	has ccache ${FEATURES} || export CCACHE_DISABLE=1
 
-	local ___phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
-	[[ -n ${___phase_func} ]] && __ebuild_phase_funcs "$EAPI" "${___phase_func}"
+	local ___phase_func=$(__ebuild_arg_to_phase "${EBUILD_PHASE}")
+	[[ -n ${___phase_func} ]] && __ebuild_phase_funcs "${EAPI}" "${___phase_func}"
 
 	__source_all_bashrcs
 
@@ -999,7 +1008,7 @@ __ebuild_main() {
 			__ebuild_phase_with_hooks pkg_${1}
 			set +x
 		fi
-		if [[ -n $PORTAGE_UPDATE_ENV ]] ; then
+		if [[ -n ${PORTAGE_UPDATE_ENV} ]] ; then
 			# Update environment.bz2 in case installation phases
 			# need to pass some variables to uninstallation phases.
 			# Use safe cwd, avoiding unsafe import for bug #469338.
@@ -1007,7 +1016,7 @@ __ebuild_main() {
 			__save_ebuild_env --exclude-init-phases | \
 				__filter_readonly_variables --filter-path \
 				--filter-sandbox --allow-extra-vars \
-				| ${PORTAGE_BZIP2_COMMAND} -c -f9 > "$PORTAGE_UPDATE_ENV"
+				| ${PORTAGE_BZIP2_COMMAND} -c -f9 > "${PORTAGE_UPDATE_ENV}"
 			assert "__save_ebuild_env failed"
 		fi
 		;;
@@ -1024,16 +1033,16 @@ __ebuild_main() {
 			local x
 			for x in ASFLAGS CCACHE_DIR CCACHE_SIZE \
 				CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do
-				[[ ${!x+set} = set ]] && export $x
+				[[ ${!x+set} = set ]] && export ${x}
 			done
 			unset x
 
-			has distcc $FEATURES && [[ -n $DISTCC_DIR ]] && \
-				[[ ${SANDBOX_WRITE/$DISTCC_DIR} = $SANDBOX_WRITE ]] && \
-				addwrite "$DISTCC_DIR"
+			has distcc ${FEATURES} && [[ -n ${DISTCC_DIR} ]] && \
+				[[ ${SANDBOX_WRITE/${DISTCC_DIR}} = ${SANDBOX_WRITE} ]] && \
+				addwrite "${DISTCC_DIR}"
 
-			if has noauto $FEATURES && \
-				[[ ! -f $PORTAGE_BUILDDIR/.unpacked ]] ; then
+			if has noauto ${FEATURES} && \
+				[[ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]] ; then
 				echo
 				echo "!!! We apparently haven't unpacked..." \
 					"This is probably not what you"
@@ -1046,14 +1055,14 @@ __ebuild_main() {
 				sleep 5
 			fi
 
-			cd "$PORTAGE_BUILDDIR"
+			cd "${PORTAGE_BUILDDIR}"
 			if [[ ! -d build-info ]]; then
 				mkdir build-info
-				cp "$EBUILD" "build-info/$PF.ebuild"
+				cp "${EBUILD}" "build-info/${PF}.ebuild"
 			fi
 
-			#our custom version of libtool uses $S and $D to fix
-			#invalid paths in .la files
+			# Our custom version of libtool uses ${S} and ${D} to fix
+			# invalid paths in .la files
 			export S D
 
 			;;
@@ -1069,9 +1078,9 @@ __ebuild_main() {
 		export SANDBOX_ON="0"
 		;;
 	help|pretend|setup)
-		#pkg_setup needs to be out of the sandbox for tmp file creation;
-		#for example, awking and piping a file in /tmp requires a temp file to be created
-		#in /etc.  If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
+		# pkg_setup needs to be out of the sandbox for tmp file creation;
+		# for example, awking and piping a file in /tmp requires a temp file to be created
+		# in /etc.  If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
 		export SANDBOX_ON="0"
 		if [[ "${PORTAGE_DEBUG}" != "1" || "${-/x/}" != "$-" ]]; then
 			__dyn_${1}
@@ -1095,17 +1104,21 @@ __ebuild_main() {
 	# Save the env only for relevant phases.
 	if ! has "${1}" clean help info nofetch ; then
 		umask 002
+
 		# Use safe cwd, avoiding unsafe import for bug #469338.
 		cd "${PORTAGE_PYM_PATH}"
 		__save_ebuild_env | __filter_readonly_variables \
-			--filter-features > "$T/environment"
+			--filter-features > "${T}/environment"
 		assert "__save_ebuild_env failed"
-		chgrp "${PORTAGE_GRPNAME:-portage}" "$T/environment"
-		chmod g+w "$T/environment"
+
+		chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/environment"
+		chmod g+w "${T}/environment"
 	fi
-	[[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
-	if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
-		[[ ! -s $SANDBOX_LOG ]]
-		"$PORTAGE_BIN_PATH"/ebuild-ipc exit $?
+
+	[[ -n ${PORTAGE_EBUILD_EXIT_FILE} ]] && > "${PORTAGE_EBUILD_EXIT_FILE}"
+	if [[ -n ${PORTAGE_IPC_DAEMON} ]] ; then
+		[[ ! -s ${SANDBOX_LOG} ]]
+
+		"${PORTAGE_BIN_PATH}"/ebuild-ipc exit $?
 	fi
 }

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 481170ebb..0f8973f59 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -16,7 +16,7 @@ export EXEOPTIONS="-m0755"
 export LIBOPTIONS="-m0644"
 export DIROPTIONS="-m0755"
 export MOPREFIX=${PN}
-# Do not compress files which are smaller than this (in bytes). #169260
+# Do not compress files which are smaller than this (in bytes), bug #169260
 export PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
 declare -a PORTAGE_DOCOMPRESS=( /usr/share/{doc,info,man} )
 declare -a PORTAGE_DOCOMPRESS_SKIP=( /usr/share/doc/${PF}/html )
@@ -34,10 +34,11 @@ into() {
 		fi
 		if [[ ! -d "${ED%/}/${_E_DESTTREE_#/}" ]]; then
 			install -d "${ED%/}/${_E_DESTTREE_#/}"
+
 			local ret=$?
-			if [[ $ret -ne 0 ]] ; then
+			if [[ ${ret} -ne 0 ]] ; then
 				__helpers_die "${FUNCNAME[0]} failed"
-				return $ret
+				return ${ret}
 			fi
 		fi
 	fi
@@ -48,19 +49,20 @@ into() {
 }
 
 insinto() {
-	if [[ "$1" == "/" ]]; then
+	if [[ "${1}" == "/" ]]; then
 		export _E_INSDESTTREE_=""
 	else
-		export _E_INSDESTTREE_=$1
+		export _E_INSDESTTREE_=${1}
 		if ! ___eapi_has_prefix_variables; then
 			local ED=${D}
 		fi
 		if [[ ! -d "${ED%/}/${_E_INSDESTTREE_#/}" ]]; then
 			install -d "${ED%/}/${_E_INSDESTTREE_#/}"
+
 			local ret=$?
-			if [[ $ret -ne 0 ]] ; then
+			if [[ ${ret} -ne 0 ]] ; then
 				__helpers_die "${FUNCNAME[0]} failed"
-				return $ret
+				return ${ret}
 			fi
 		fi
 	fi
@@ -71,38 +73,39 @@ insinto() {
 }
 
 exeinto() {
-	if [[ "$1" == "/" ]]; then
+	if [[ "${1}" == "/" ]]; then
 		export _E_EXEDESTTREE_=""
 	else
-		export _E_EXEDESTTREE_="$1"
+		export _E_EXEDESTTREE_="${1}"
 		if ! ___eapi_has_prefix_variables; then
 			local ED=${D}
 		fi
 		if [[ ! -d "${ED%/}/${_E_EXEDESTTREE_#/}" ]]; then
 			install -d "${ED%/}/${_E_EXEDESTTREE_#/}"
+
 			local ret=$?
-			if [[ $ret -ne 0 ]] ; then
+			if [[ ${ret} -ne 0 ]] ; then
 				__helpers_die "${FUNCNAME[0]} failed"
-				return $ret
+				return ${ret}
 			fi
 		fi
 	fi
 }
 
 docinto() {
-	if [[ "$1" == "/" ]]; then
+	if [[ "${1}" == "/" ]]; then
 		export _E_DOCDESTTREE_=""
 	else
-		export _E_DOCDESTTREE_="$1"
+		export _E_DOCDESTTREE_="${1}"
 		if ! ___eapi_has_prefix_variables; then
 			local ED=${D}
 		fi
 		if [[ ! -d "${ED%/}/usr/share/doc/${PF}/${_E_DOCDESTTREE_#/}" ]]; then
 			install -d "${ED%/}/usr/share/doc/${PF}/${_E_DOCDESTTREE_#/}"
 			local ret=$?
-			if [[ $ret -ne 0 ]] ; then
+			if [[ ${ret} -ne 0 ]] ; then
 				__helpers_die "${FUNCNAME[0]} failed"
-				return $ret
+				return ${ret}
 			fi
 		fi
 	fi
@@ -128,7 +131,7 @@ exeopts() {
 
 libopts() {
 	if ! ___eapi_has_dolib_libopts; then
-		die "'${FUNCNAME}' has been banned for EAPI '$EAPI'"
+		die "'${FUNCNAME}' has been banned for EAPI '${EAPI}'"
 	fi
 
 	export LIBOPTIONS="$@"
@@ -141,8 +144,9 @@ docompress() {
 	___eapi_has_docompress || die "'docompress' not supported in this EAPI"
 
 	local f g
-	if [[ $1 = "-x" ]]; then
+	if [[ ${1} = "-x" ]]; then
 		shift
+
 		for f; do
 			f=$(__strip_duplicate_slashes "${f}"); f=${f%/}
 			[[ ${f:0:1} = / ]] || f="/${f}"
@@ -229,13 +233,13 @@ use() {
 		found=1
 	fi
 
-	if [[ $EBUILD_PHASE = depend ]] ; then
+	if [[ ${EBUILD_PHASE} = depend ]] ; then
 		# TODO: Add a registration interface for eclasses to register
 		# any number of phase hooks, so that global scope eclass
 		# initialization can by migrated to phase hooks in new EAPIs.
-		# Example: add_phase_hook before pkg_setup $ECLASS_pre_pkg_setup
-		#if [[ -n $EAPI ]] && ! has "$EAPI" 0 1 2 3 ; then
-		#	die "use() called during invalid phase: $EBUILD_PHASE"
+		# Example: add_phase_hook before pkg_setup ${ECLASS}_pre_pkg_setup
+		#if [[ -n ${EAPI} ]] && ! has "${EAPI}" 0 1 2 3 ; then
+		#	die "use() called during invalid phase: ${EBUILD_PHASE}"
 		#fi
 		true
 
@@ -251,6 +255,7 @@ use() {
 				# is not well defined for earlier EAPIs (see bug #449708).
 				die "USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}"
 			fi
+
 			eqawarn "QA Notice: USE Flag '${u}' not" \
 				"in IUSE for ${CATEGORY}/${PF}"
 		fi
@@ -268,7 +273,7 @@ use() {
 }
 
 use_with() {
-	if [[ -z "$1" ]]; then
+	if [[ -z "${1}" ]]; then
 		echo "!!! use_with() called without a parameter." >&2
 		echo "!!! use_with <USEFLAG> [<flagname> [value]]" >&2
 		return 1
@@ -281,7 +286,7 @@ use_with() {
 	fi
 	local UWORD=${2:-$1}
 
-	if use $1; then
+	if use ${1}; then
 		echo "--with-${UWORD}${UW_SUFFIX}"
 	else
 		echo "--without-${UWORD}"
@@ -290,7 +295,7 @@ use_with() {
 }
 
 use_enable() {
-	if [[ -z "$1" ]]; then
+	if [[ -z "${1}" ]]; then
 		echo "!!! use_enable() called without a parameter." >&2
 		echo "!!! use_enable <USEFLAG> [<flagname> [value]]" >&2
 		return 1
@@ -303,7 +308,7 @@ use_enable() {
 	fi
 	local UWORD=${2:-$1}
 
-	if use $1; then
+	if use ${1}; then
 		echo "--enable-${UWORD}${UE_SUFFIX}"
 	else
 		echo "--disable-${UWORD}"
@@ -318,6 +323,7 @@ unpack() {
 	local suffix suffix_insensitive
 	local myfail
 	local eapi=${EAPI:-0}
+
 	[[ -z "$*" ]] && die "Nothing passed to the 'unpack' command"
 
 	for x in "$@"; do
@@ -362,12 +368,12 @@ unpack() {
 						"secondary suffix '${y}' which is unofficially" \
 						"supported with EAPI '${EAPI}'. Instead use 'tar'."
 				fi
-				$1 -c -- "$srcdir$x" | tar xof -
-				__assert_sigpipe_ok "$myfail"
+				$1 -c -- "${srcdir}${x}" | tar xof -
+				__assert_sigpipe_ok "${myfail}"
 			else
 				local cwd_dest=${x##*/}
 				cwd_dest=${cwd_dest%.*}
-				$1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail"
+				$1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "${myfail}"
 			fi
 		}
 
@@ -380,7 +386,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'tar'."
 				fi
-				tar xof "$srcdir$x" || die "$myfail"
+				tar xof "${srcdir}${x}" || die "${myfail}"
 				;;
 			tgz)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -389,7 +395,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'tgz'."
 				fi
-				tar xozf "$srcdir$x" || die "$myfail"
+				tar xozf "${srcdir}${x}" || die "${myfail}"
 				;;
 			tbz|tbz2)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -398,8 +404,8 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'tbz' or 'tbz2'."
 				fi
-				${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
-				__assert_sigpipe_ok "$myfail"
+				${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "${srcdir}${x}" | tar xof -
+				__assert_sigpipe_ok "${myfail}"
 				;;
 			zip|jar)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -412,7 +418,7 @@ unpack() {
 				# unzip will interactively prompt under some error conditions,
 				# as reported in bug #336285
 				( set +x ; while true ; do echo n || break ; done ) | \
-				unzip -qo "${srcdir}${x}" || die "$myfail"
+				unzip -qo "${srcdir}${x}" || die "${myfail}"
 				;;
 			gz|z)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -438,7 +444,7 @@ unpack() {
 					my_output="$(7z x -y "${srcdir}${x}")"
 					if [[ $? -ne 0 ]]; then
 						echo "${my_output}" >&2
-						die "$myfail"
+						die "${myfail}"
 					fi
 				else
 					__vecho "unpack ${x}: file format not recognized. Ignoring."
@@ -452,7 +458,7 @@ unpack() {
 						"with EAPI '${EAPI}'. Instead use 'rar' or 'RAR'."
 				fi
 				if ___eapi_unpack_supports_rar; then
-					unrar x -idq -o+ "${srcdir}${x}" || die "$myfail"
+					unrar x -idq -o+ "${srcdir}${x}" || die "${myfail}"
 				else
 					__vecho "unpack ${x}: file format not recognized. Ignoring."
 				fi
@@ -466,7 +472,7 @@ unpack() {
 						"Instead use 'LHA', 'LHa', 'lha', or 'lzh'."
 				fi
 				if ___eapi_unpack_supports_lha; then
-					lha xfq "${srcdir}${x}" || die "$myfail"
+					lha xfq "${srcdir}${x}" || die "${myfail}"
 				else
 					__vecho "unpack ${x}: file format not recognized. Ignoring."
 				fi
@@ -478,7 +484,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'a'."
 				fi
-				ar x "${srcdir}${x}" || die "$myfail"
+				ar x "${srcdir}${x}" || die "${myfail}"
 				;;
 			deb)
 				if ___eapi_unpack_is_case_sensitive && \
@@ -487,6 +493,7 @@ unpack() {
 						"suffix '${suffix}' which is unofficially supported" \
 						"with EAPI '${EAPI}'. Instead use 'deb'."
 				fi
+
 				# Unpacking .deb archives can not always be done with
 				# `ar`.  For instance on AIX this doesn't work out.
 				# If `ar` is not the GNU binutils version and we have
@@ -497,24 +504,27 @@ unpack() {
 					type -P deb2targz > /dev/null; then
 					y=${x##*/}
 					local created_symlink=0
-					if [[ ! "$srcdir$x" -ef "$y" ]]; then
+
+					if [[ ! "${srcdir}${x}" -ef "${y}" ]]; then
 						# deb2targz always extracts into the same directory as
 						# the source file, so create a symlink in the current
 						# working directory if necessary.
-						ln -sf "$srcdir$x" "$y" || die "$myfail"
+						ln -sf "${srcdir}${x}" "${y}" || die "${myfail}"
 						created_symlink=1
 					fi
-					deb2targz "$y" || die "$myfail"
-					if [[ $created_symlink = 1 ]]; then
+
+					deb2targz "${y}" || die "${myfail}"
+
+					if [[ ${created_symlink} = 1 ]]; then
 						# Clean up the symlink so the ebuild
 						# doesn't inadvertently install it.
-						rm -f "$y"
+						rm -f "${y}"
 					fi
 					mv -f "${y%.deb}".tar.gz data.tar.gz \
 						|| mv -f "${y%.deb}".tar.xz data.tar.xz \
-						|| die "$myfail"
+						|| die "${myfail}"
 				else
-					ar x "$srcdir$x" || die "$myfail"
+					ar x "${srcdir}${x}" || die "${myfail}"
 				fi
 				;;
 			lzma)
@@ -547,7 +557,7 @@ unpack() {
 						"with EAPI '${EAPI}'. Instead use 'txz'."
 				fi
 				if ___eapi_unpack_supports_txz; then
-					tar xof "$srcdir$x" || die "$myfail"
+					tar xof "${srcdir}${x}" || die "${myfail}"
 				else
 					__vecho "unpack ${x}: file format not recognized. Ignoring."
 				fi
@@ -557,6 +567,7 @@ unpack() {
 				;;
 		esac
 	done
+
 	# Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
 	# should be preserved.
 	find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \
@@ -580,38 +591,42 @@ econf() {
 
 	__hasgq() { __hasg "$@" >/dev/null ; }
 
-	local phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
-	if [[ -n $phase_func ]] ; then
+	local phase_func=$(__ebuild_arg_to_phase "${EBUILD_PHASE}")
+	if [[ -n ${phase_func} ]] ; then
 		if ! ___eapi_has_src_configure; then
-			[[ $phase_func != src_compile ]] && \
+			[[ ${phase_func} != src_compile ]] && \
 				eqawarn "QA Notice: econf called in" \
-					"$phase_func instead of src_compile"
+					"${phase_func} instead of src_compile"
 		else
-			[[ $phase_func != src_configure ]] && \
+			[[ ${phase_func} != src_configure ]] && \
 				eqawarn "QA Notice: econf called in" \
-					"$phase_func instead of src_configure"
+					"${phase_func} instead of src_configure"
 		fi
 	fi
 
 	: ${ECONF_SOURCE:=.}
 	if [[ -x "${ECONF_SOURCE}/configure" ]]; then
-		if [[ -n $CONFIG_SHELL && \
-			"$(head -n1 "$ECONF_SOURCE/configure")" =~ ^'#!'[[:space:]]*/bin/sh([[:space:]]|$) ]] ; then
+		if [[ -n ${CONFIG_SHELL} && \
+			"$(head -n1 "${ECONF_SOURCE}/configure")" =~ ^'#!'[[:space:]]*/bin/sh([[:space:]]|$) ]] ; then
+
 			cp -p "${ECONF_SOURCE}/configure" "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" || die
 			sed -i \
-				-e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" \
+				-e "1s:^#![[:space:]]*/bin/sh:#!${CONFIG_SHELL}:" \
 				"${ECONF_SOURCE}/configure._portage_tmp_.${pid}" \
 				|| die "Substition of shebang in '${ECONF_SOURCE}/configure' failed"
+
 			# Preserve timestamp, see bug #440304
 			touch -r "${ECONF_SOURCE}/configure" "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" || die
 			mv -f "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" "${ECONF_SOURCE}/configure" || die
 		fi
+
 		if [[ -e "${EPREFIX}"/usr/share/gnuconfig/ ]]; then
 			find "${WORKDIR}" -type f '(' \
 			-name config.guess -o -name config.sub ')' -print0 | \
 			while read -r -d $'\0' x ; do
 				__vecho " * econf: updating ${x/${WORKDIR}\/} with ${EPREFIX}/usr/share/gnuconfig/${x##*/}"
-				# Make sure we do this atomically incase we're run in parallel. #487478
+
+				# Make sure we do this atomically incase we're run in parallel, bug #487478
 				cp -f "${EPREFIX}"/usr/share/gnuconfig/"${x##*/}" "${x}.${pid}"
 				mv -f "${x}.${pid}" "${x}"
 			done
@@ -669,13 +684,17 @@ econf() {
 		if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
 			CONF_LIBDIR=${!LIBDIR_VAR}
 		fi
+
 		if [[ -n ${CONF_LIBDIR} ]] && ! __hasgq --libdir=\* "$@" ; then
 			export CONF_PREFIX=$(__hasg --exec-prefix=\* "$@")
 			[[ -z ${CONF_PREFIX} ]] && CONF_PREFIX=$(__hasg --prefix=\* "$@")
+
 			: ${CONF_PREFIX:=${EPREFIX}/usr}
 			CONF_PREFIX=${CONF_PREFIX#*=}
+
 			[[ ${CONF_PREFIX} != /* ]] && CONF_PREFIX="/${CONF_PREFIX}"
 			[[ ${CONF_LIBDIR} != /* ]] && CONF_LIBDIR="/${CONF_LIBDIR}"
+
 			conf_args+=(
 				--libdir="$(__strip_duplicate_slashes "${CONF_PREFIX}${CONF_LIBDIR}")"
 			)
@@ -700,12 +719,12 @@ econf() {
 		__vecho "${ECONF_SOURCE}/configure" "$@"
 
 		if ! "${ECONF_SOURCE}/configure" "$@" ; then
-
 			if [[ -s config.log ]]; then
 				echo
 				echo "!!! Please attach the following file when seeking support:"
 				echo "!!! ${PWD}/config.log"
 			fi
+
 			# econf dies unconditionally in EAPIs 0 to 3
 			___eapi_helpers_can_die || die "econf failed"
 			__helpers_die "econf failed"
@@ -720,7 +739,7 @@ econf() {
 
 einstall() {
 	if ! ___eapi_has_einstall; then
-		die "'${FUNCNAME}' has been banned for EAPI '$EAPI'"
+		die "'${FUNCNAME}' has been banned for EAPI '${EAPI}'"
 		exit 1
 	fi
 
@@ -729,11 +748,13 @@ einstall() {
 	if ! ___eapi_has_prefix_variables; then
 		local ED=${D}
 	fi
+
 	LIBDIR_VAR="LIBDIR_${ABI}"
 	if [[ -n "${ABI}" && -n "${!LIBDIR_VAR}" ]]; then
 		CONF_LIBDIR="${!LIBDIR_VAR}"
 	fi
 	unset LIBDIR_VAR
+
 	if [[ -n "${CONF_LIBDIR}" && "${CONF_PREFIX:+set}" = set ]]; then
 		EI_DESTLIBDIR="${D%/}/${CONF_PREFIX}/${CONF_LIBDIR}"
 		EI_DESTLIBDIR="$(__strip_duplicate_slashes "${EI_DESTLIBDIR}")"
@@ -753,6 +774,7 @@ einstall() {
 				${MAKEOPTS} -j1 \
 				"$@" ${EXTRA_EMAKE} install
 		fi
+
 		if ! ${MAKE:-make} prefix="${ED%/}/usr" \
 			datadir="${ED%/}/usr/share" \
 			infodir="${ED%/}/usr/share/info" \
@@ -803,13 +825,14 @@ __eapi0_src_test() {
 	if ___eapi_default_src_test_disables_parallel_jobs; then
 		internal_opts+=" -j1"
 	fi
-	if $emake_cmd ${internal_opts} check -n &> /dev/null; then
+
+	if ${emake_cmd} ${internal_opts} check -n &> /dev/null; then
 		__vecho "${emake_cmd} ${internal_opts} check" >&2
-		$emake_cmd ${internal_opts} check || \
+		${emake_cmd} ${internal_opts} check || \
 			die "Make check failed. See above for details."
-	elif $emake_cmd ${internal_opts} test -n &> /dev/null; then
+	elif ${emake_cmd} ${internal_opts} test -n &> /dev/null; then
 		__vecho "${emake_cmd} ${internal_opts} test" >&2
-		$emake_cmd ${internal_opts} test || \
+		${emake_cmd} ${internal_opts} test || \
 			die "Make test failed. See above for details."
 	fi
 }
@@ -904,6 +927,7 @@ ___best_version_and_has_version_common() {
 			if ! ___eapi_best_version_and_has_version_support_--host-root; then
 				die "${FUNCNAME[1]}: option ${root_arg} is not supported with EAPI ${EAPI}"
 			fi
+
 			if ___eapi_has_prefix_variables; then
 				# Since portageq requires the root argument be consistent
 				# with EPREFIX, ensure consistency here (bug #655414).
@@ -936,13 +960,15 @@ ___best_version_and_has_version_common() {
 			fi ;;
 	esac
 
-	if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
+	if [[ -n ${PORTAGE_IPC_DAEMON} ]] ; then
 		cmd+=("${PORTAGE_BIN_PATH}"/ebuild-ipc "${FUNCNAME[1]}" "${root}" "${atom}")
 	else
 		cmd+=("${PORTAGE_BIN_PATH}"/ebuild-helpers/portageq "${FUNCNAME[1]}" "${root}" "${atom}")
 	fi
+
 	"${cmd[@]}"
 	local retval=$?
+
 	case "${retval}" in
 		0|1)
 			return ${retval}
@@ -1040,6 +1066,7 @@ if ___eapi_has_eapply; then
 				-p1 -f -g0 --no-backup-if-mismatch
 				"${patch_options[@]}"
 			)
+
 			# Try applying with -F0 first, output a verbose warning
 			# if fuzz factor is necessary
 			if ${patch_cmd} "${all_opts[@]}" --dry-run -s -F0 \
@@ -1056,7 +1083,7 @@ if ___eapi_has_eapply; then
 
 		local patch_options=() files=()
 		local i found_doublehyphen
-		# first, try to split on --
+		# First, try to split on --
 		for (( i = 1; i <= ${#@}; ++i )); do
 			if [[ ${@:i:1} == -- ]]; then
 				patch_options=( "${@:1:i-1}" )
@@ -1066,7 +1093,7 @@ if ___eapi_has_eapply; then
 			fi
 		done
 
-		# then, try to split on first non-option
+		# Then, try to split on first non-option
 		if [[ -z ${found_doublehyphen} ]]; then
 			for (( i = 1; i <= ${#@}; ++i )); do
 				if [[ ${@:i:1} != -* ]]; then
@@ -1076,7 +1103,7 @@ if ___eapi_has_eapply; then
 				fi
 			done
 
-			# ensure that no options were interspersed with files
+			# Ensure that no options were interspersed with files
 			for i in "${files[@]}"; do
 				if [[ ${i} == -* ]]; then
 					die "eapply: all options must be passed before non-options"
@@ -1119,7 +1146,7 @@ if ___eapi_has_eapply; then
 			else
 				_eapply_patch "${f}"
 
-				# in case of nonfatal
+				# In case of nonfatal
 				[[ ${failed} -ne 0 ]] && return "${failed}"
 			fi
 		done
@@ -1132,6 +1159,7 @@ if ___eapi_has_eapply_user; then
 	eapply_user() {
 		[[ ${EBUILD_PHASE} == prepare ]] || \
 			die "eapply_user() called during invalid phase: ${EBUILD_PHASE}"
+
 		# Keep path in __dyn_prepare in sync!
 		local tagfile=${T}/.portage_user_patches_applied
 		[[ -f ${tagfile} ]] && return

diff --git a/bin/portageq b/bin/portageq
index 6d12c98dd..70c5699bb 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -956,7 +956,7 @@ def get_repos(argv):
 docstrings[
     "get_repos"
 ] = """<eroot>
-	Returns all repos with names (repo_name file) argv[0] = $EROOT
+	Returns all repos with names (repo_name file) argv[0] = ${EROOT}
 	"""
 get_repos.__doc__ = docstrings["get_repos"]
 
@@ -1023,7 +1023,7 @@ def get_repo_path(argv):
 docstrings[
     "get_repo_path"
 ] = """<eroot> <repo_id>+
-	Returns the path to the repo named argv[1], argv[0] = $EROOT
+	Returns the path to the repo named argv[1], argv[0] = ${EROOT}
 	"""
 get_repo_path.__doc__ = docstrings["get_repo_path"]
 

diff --git a/bin/postinst-qa-check.d/50xdg-utils b/bin/postinst-qa-check.d/50xdg-utils
index 9a7c036e6..2951ae05c 100644
--- a/bin/postinst-qa-check.d/50xdg-utils
+++ b/bin/postinst-qa-check.d/50xdg-utils
@@ -1,4 +1,4 @@
-# check for missing calls to xdg-utils regen functions
+# Check for missing calls to xdg-utils regen functions
 
 xdg_desktop_database_check() {
 	type -P update-desktop-database &>/dev/null || return
@@ -8,19 +8,19 @@ xdg_desktop_database_check() {
 		[[ -d ${d} ]] || continue
 
 		local files=() find_args=()
-		# if the cache does not exist at all, we complain for any file
+		# If the cache does not exist at all, we complain for any file
 		# otherwise, we look for files newer than the cache
 		[[ -f ${d}/mimeinfo.cache ]] &&
 			find_args+=( -newercm "${d}"/mimeinfo.cache ) || missing=1
 
-		# look for any .desktop files that are newer than the cache
+		# Look for any .desktop files that are newer than the cache
 		# and that have any mime types defined
 		while read -r -d $'\0' f; do
 			files+=( "${f}" )
 		done < <(find "${d}" -name '*.desktop' "${find_args[@]}" \
 			-exec grep -lZi '^MimeType=' {} +)
 
-		# if any files were found, update the db to avoid repeating
+		# If any files were found, update the db to avoid repeating
 		# the warning for subsequent packages
 		if [[ ${files[@]} ]]; then
 			all_files+=("${files[@]}")
@@ -29,10 +29,10 @@ xdg_desktop_database_check() {
 		fi
 	done
 
-	# preinst initializes the baseline state for the posinst check
+	# Preinst initializes the baseline state for the posinst check
 	[[ ${PORTAGE_QA_PHASE} == preinst ]] && return
 
-	# parallel-install makes it impossible to blame a specific package
+	# Parallel-install makes it impossible to blame a specific package
 	has parallel-install ${FEATURES} && return
 
 	# The eqatag call is prohibitively expensive if the cache is
@@ -60,7 +60,8 @@ xdg_icon_cache_check() {
 			'(' -name '*.png' -o -name '*.svg'
 				-o -name '*.xpm' -o -name '*.icon' ')'
 		)
-		# if the cache does not exist at all, we complain for any file
+
+		# If the cache does not exist at all, we complain for any file
 		# otherwise, we look for files newer than the cache
 		[[ -f ${d}/icon-theme.cache ]] &&
 			find_args+=( -newercm "${d}"/icon-theme.cache ) || missing=1
@@ -70,7 +71,7 @@ xdg_icon_cache_check() {
 			files+=( "${f}" )
 		done < <(find "${d}" -mindepth 2 -type f "${find_args[@]}" -print0)
 
-		# if any files were found, update the db to avoid repeating
+		# If any files were found, update the db to avoid repeating
 		# the warning for subsequent packages
 		if [[ ${files[@]} ]]; then
 			all_files+=("${files[@]}")
@@ -85,7 +86,7 @@ xdg_icon_cache_check() {
 	# parallel-install makes it impossible to blame a specific package
 	has parallel-install ${FEATURES} && return
 
-	# avoid false-positives on first install (bug 649464)
+	# Avoid false-positives on first install (bug #649464)
 	[[ ${PN} == gtk-update-icon-cache ]] && return
 
 	# The eqatag call is prohibitively expensive if the cache is
@@ -107,7 +108,7 @@ xdg_mimeinfo_database_check() {
 		[[ -d ${d} ]] || continue
 
 		local files=() find_args=()
-		# if the cache does not exist at all, we complain for any file
+		# If the cache does not exist at all, we complain for any file
 		# otherwise, we look for files newer than the cache
 		[[ -f ${d}/mime.cache ]] &&
 			find_args+=( -newercm "${d}"/mime.cache ) || missing=1

diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index 18a82ad4c..eb57c9208 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -16,9 +16,9 @@ __save_ebuild_env() {
 		unset S _E_DESTTREE _E_INSDESTTREE _E_DOCDESTTREE_ _E_EXEDESTTREE_ \
 			PORTAGE_DOCOMPRESS_SIZE_LIMIT PORTAGE_DOCOMPRESS \
 			PORTAGE_DOCOMPRESS_SKIP PORTAGE_DOSTRIP PORTAGE_DOSTRIP_SKIP
-		if [[ -n $PYTHONPATH &&
-			${PYTHONPATH%%:*} -ef $PORTAGE_PYM_PATH ]] ; then
-			if [[ $PYTHONPATH == *:* ]] ; then
+		if [[ -n ${PYTHONPATH} &&
+			${PYTHONPATH%%:*} -ef ${PORTAGE_PYM_PATH} ]] ; then
+			if [[ ${PYTHONPATH} == *:* ]] ; then
 				export PYTHONPATH=${PYTHONPATH#*:}
 			else
 				unset PYTHONPATH
@@ -43,7 +43,7 @@ __save_ebuild_env() {
 	for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \
 		src_compile src_test src_install pkg_preinst pkg_postinst \
 		pkg_prerm pkg_postrm pkg_config pkg_info pkg_pretend ; do
-		unset -f default_$x __eapi{0,1,2,3,4}_$x
+		unset -f default_${x} __eapi{0,1,2,3,4}_${x}
 	done
 	unset x
 


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-01 22:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-01 22:39 [gentoo-commits] proj/portage:master commit in: bin/ebuild-helpers/xattr/, bin/ebuild-helpers/, bin/postinst-qa-check.d/, bin/, Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox