commit:     5ebec80b176a0493fde0b8f2278ed507ec0ec8d7
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri May  6 11:26:18 2022 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun May 22 14:50:46 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5ebec80b

bin/*.sh: use bash's extended-test builtin ('[[' and ']]')

The following sed was basically used to transform POSIX test to bash's
extended-test builtin:

sed -i \
  -e 's:\(\s\)\[ :\1[[ :' \
  -e 's: ] \?;: ]];:' \
  -e 's: ] : ]] :' \
  bin/*.sh

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 bin/ebuild.sh             | 76 +++++++++++++++++++++++------------------------
 bin/isolated-functions.sh | 16 +++++-----
 bin/misc-functions.sh     | 32 ++++++++++----------
 bin/phase-functions.sh    | 34 ++++++++++-----------
 bin/phase-helpers.sh      | 48 +++++++++++++++---------------
 5 files changed, 103 insertions(+), 103 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index ec96c757d..056372283 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -224,7 +224,7 @@ inherit() {
        local B_IDEPEND
        local B_PROPERTIES
        local B_RESTRICT
-       while [ "$1" ]; do
+       while [[ "$1" ]]; do
                location=""
                potential_location=""
 
@@ -269,13 +269,13 @@ inherit() {
                        # Retain the old data and restore it later.
                        unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND
                        unset B_BDEPEND B_IDEPEND B_PROPERTIES B_RESTRICT
-                       [ "${IUSE+set}"       = set ] && B_IUSE="${IUSE}"
-                       [ "${REQUIRED_USE+set}" = set ] && 
B_REQUIRED_USE="${REQUIRED_USE}"
-                       [ "${DEPEND+set}"     = set ] && B_DEPEND="${DEPEND}"
-                       [ "${RDEPEND+set}"    = set ] && B_RDEPEND="${RDEPEND}"
-                       [ "${PDEPEND+set}"    = set ] && B_PDEPEND="${PDEPEND}"
-                       [ "${BDEPEND+set}"    = set ] && B_BDEPEND="${BDEPEND}"
-                       [ "${IDEPEND+set}"    = set ] && B_IDEPEND="${IDEPEND}"
+                       [[ "${IUSE+set}"       = set ]] && B_IUSE="${IUSE}"
+                       [[ "${REQUIRED_USE+set}" = set ]] && 
B_REQUIRED_USE="${REQUIRED_USE}"
+                       [[ "${DEPEND+set}"     = set ]] && B_DEPEND="${DEPEND}"
+                       [[ "${RDEPEND+set}"    = set ]] && 
B_RDEPEND="${RDEPEND}"
+                       [[ "${PDEPEND+set}"    = set ]] && 
B_PDEPEND="${PDEPEND}"
+                       [[ "${BDEPEND+set}"    = set ]] && 
B_BDEPEND="${BDEPEND}"
+                       [[ "${IDEPEND+set}"    = set ]] && 
B_IDEPEND="${IDEPEND}"
                        unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND BDEPEND 
IDEPEND
 
                        if ___eapi_has_accumulated_PROPERTIES; then
@@ -299,34 +299,34 @@ inherit() {
 
                        # If each var has a value, append it to the global 
variable E_* to
                        # be applied after everything is finished. New 
incremental behavior.
-                       [ "${IUSE+set}"         = set ] && E_IUSE+="${E_IUSE:+ 
}${IUSE}"
-                       [ "${REQUIRED_USE+set}" = set ] && 
E_REQUIRED_USE+="${E_REQUIRED_USE:+ }${REQUIRED_USE}"
-                       [ "${DEPEND+set}"       = set ] && 
E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
-                       [ "${RDEPEND+set}"      = set ] && 
E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
-                       [ "${PDEPEND+set}"      = set ] && 
E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
-                       [ "${BDEPEND+set}"      = set ] && 
E_BDEPEND+="${E_BDEPEND:+ }${BDEPEND}"
-                       [ "${IDEPEND+set}"      = set ] && 
E_IDEPEND+="${E_IDEPEND:+ }${IDEPEND}"
+                       [[ "${IUSE+set}"         = set ]] && 
E_IUSE+="${E_IUSE:+ }${IUSE}"
+                       [[ "${REQUIRED_USE+set}" = set ]] && 
E_REQUIRED_USE+="${E_REQUIRED_USE:+ }${REQUIRED_USE}"
+                       [[ "${DEPEND+set}"       = set ]] && 
E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
+                       [[ "${RDEPEND+set}"      = set ]] && 
E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
+                       [[ "${PDEPEND+set}"      = set ]] && 
E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
+                       [[ "${BDEPEND+set}"      = set ]] && 
E_BDEPEND+="${E_BDEPEND:+ }${BDEPEND}"
+                       [[ "${IDEPEND+set}"      = set ]] && 
E_IDEPEND+="${E_IDEPEND:+ }${IDEPEND}"
 
-                       [ "${B_IUSE+set}"     = set ] && IUSE="${B_IUSE}"
-                       [ "${B_IUSE+set}"     = set ] || unset IUSE
+                       [[ "${B_IUSE+set}"     = set ]] && IUSE="${B_IUSE}"
+                       [[ "${B_IUSE+set}"     = set ]] || unset IUSE
 
-                       [ "${B_REQUIRED_USE+set}"     = set ] && 
REQUIRED_USE="${B_REQUIRED_USE}"
-                       [ "${B_REQUIRED_USE+set}"     = set ] || unset 
REQUIRED_USE
+                       [[ "${B_REQUIRED_USE+set}"     = set ]] && 
REQUIRED_USE="${B_REQUIRED_USE}"
+                       [[ "${B_REQUIRED_USE+set}"     = set ]] || unset 
REQUIRED_USE
 
-                       [ "${B_DEPEND+set}"   = set ] && DEPEND="${B_DEPEND}"
-                       [ "${B_DEPEND+set}"   = set ] || unset DEPEND
+                       [[ "${B_DEPEND+set}"   = set ]] && DEPEND="${B_DEPEND}"
+                       [[ "${B_DEPEND+set}"   = set ]] || unset DEPEND
 
-                       [ "${B_RDEPEND+set}"  = set ] && RDEPEND="${B_RDEPEND}"
-                       [ "${B_RDEPEND+set}"  = set ] || unset RDEPEND
+                       [[ "${B_RDEPEND+set}"  = set ]] && 
RDEPEND="${B_RDEPEND}"
+                       [[ "${B_RDEPEND+set}"  = set ]] || unset RDEPEND
 
-                       [ "${B_PDEPEND+set}"  = set ] && PDEPEND="${B_PDEPEND}"
-                       [ "${B_PDEPEND+set}"  = set ] || unset PDEPEND
+                       [[ "${B_PDEPEND+set}"  = set ]] && 
PDEPEND="${B_PDEPEND}"
+                       [[ "${B_PDEPEND+set}"  = set ]] || unset PDEPEND
 
-                       [ "${B_BDEPEND+set}"  = set ] && BDEPEND="${B_BDEPEND}"
-                       [ "${B_BDEPEND+set}"  = set ] || unset BDEPEND
+                       [[ "${B_BDEPEND+set}"  = set ]] && 
BDEPEND="${B_BDEPEND}"
+                       [[ "${B_BDEPEND+set}"  = set ]] || unset BDEPEND
 
-                       [ "${B_IDEPEND+set}"  = set ] && IDEPEND="${B_IDEPEND}"
-                       [ "${B_IDEPEND+set}"  = set ] || unset IDEPEND
+                       [[ "${B_IDEPEND+set}"  = set ]] && 
IDEPEND="${B_IDEPEND}"
+                       [[ "${B_IDEPEND+set}"  = set ]] || unset IDEPEND
 
                        if ___eapi_has_accumulated_PROPERTIES; then
                                [[ ${PROPERTIES+set} == set ]] &&
@@ -375,7 +375,7 @@ 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+=\" $*\"
@@ -416,8 +416,8 @@ __source_all_bashrcs() {
                __source_env_files --no-qa "${PM_EBUILD_HOOK_DIR}"
        fi
 
-       [ ! -z "${OCC}" ] && export CC="${OCC}"
-       [ ! -z "${OCXX}" ] && export CXX="${OCXX}"
+       [[ ! -z "${OCC}" ]] && export CC="${OCC}"
+       [[ ! -z "${OCXX}" ]] && export CXX="${OCXX}"
 }
 
 # @FUNCTION: __source_env_files
@@ -490,14 +490,14 @@ fi
 if [[ -n ${QA_INTERCEPTORS} ]] ; then
        for BIN in ${QA_INTERCEPTORS}; do
                BIN_PATH=$(type -Pf ${BIN})
-               if [ "$?" != "0" ]; then
+               if [[ "$?" != "0" ]]; then
                        BODY="echo \"*** missing command: ${BIN}\" >&2; return 
127"
                else
                        BODY="${BIN_PATH} \"\$@\"; return \$?"
                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}\"
@@ -532,7 +532,7 @@ trap 'exit 1' SIGTERM
 
 if ! has "$EBUILD_PHASE" clean cleanrm depend && \
        ! [[ $EMERGE_FROM = ebuild && $EBUILD_PHASE = setup ]] && \
-       [ -f "${T}"/environment ] ; then
+       [[ -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.
@@ -554,9 +554,9 @@ if ! has "$EBUILD_PHASE" clean cleanrm depend && \
        export SANDBOX_ON=0
        for x in SANDBOX_DENY SANDBOX_PREDICT SANDBOX_READ SANDBOX_WRITE ; do
                y="PORTAGE_${x}"
-               if [ -z "${!x}" ] ; then
+               if [[ -z "${!x}" ]]; then
                        export ${x}="${!y}"
-               elif [ -n "${!y}" ] && [ "${!y}" != "${!x}" ] ; then
+               elif [[ -n "${!y}" ]] && [[ "${!y}" != "${!x}" ]]; then
                        # filter out dupes
                        export ${x}="$(printf "${!y}:${!x}" | tr ":" "\0" | \
                                sort -z -u | tr "\0" ":")"
@@ -619,7 +619,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
                        shopt -u failglob
                fi
 
-               [ "${EAPI+set}" = set ] || EAPI=0
+               [[ "${EAPI+set}" = set ]] || EAPI=0
 
                # export EAPI for helpers (especially since we unset it above)
                export EAPI

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 912782914..848e44b04 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -61,7 +61,7 @@ __dump_trace() {
        (( n = ${#FUNCNAME[@]} - 1 ))
        (( p = ${#BASH_ARGV[@]} ))
        while (( n > 0 )) ; do
-               [ "${FUNCNAME[${n}]}" == "__qa_call" ] && break
+               [[ "${FUNCNAME[${n}]}" == "__qa_call" ]] && break
                (( p -= ${BASH_ARGC[${n}]} ))
                (( n-- ))
        done
@@ -132,7 +132,7 @@ die() {
        fi
 
        set +e
-       if [ -n "${QA_INTERCEPTORS}" ] ; then
+       if [[ -n "${QA_INTERCEPTORS}" ]]; then
                # die was called from inside inherit. We need to clean up
                # QA_INTERCEPTORS since sed is called below.
                unset -f ${QA_INTERCEPTORS}
@@ -142,7 +142,7 @@ die() {
        # setup spacing to make output easier to read
        (( n = ${#FUNCNAME[@]} - 1 ))
        while (( n > 0 )) ; do
-               [ "${FUNCNAME[${n}]}" == "__qa_call" ] && break
+               [[ "${FUNCNAME[${n}]}" == "__qa_call" ]] && break
                (( n-- ))
        done
        (( n == 0 )) && (( n = ${#FUNCNAME[@]} - 1 ))
@@ -217,9 +217,9 @@ die() {
                        eerror "For convenience, a symlink to the build log is 
located at '${T}/build.${log_ext}'."
                fi
        fi
-       if [ -f "${T}/environment" ] ; then
+       if [[ -f "${T}/environment" ]]; then
                eerror "The ebuild environment file is located at 
'${T}/environment'."
-       elif [ -d "${T}" ] ; then
+       elif [[ -d "${T}" ]]; then
                {
                        set
                        export
@@ -250,7 +250,7 @@ __vecho() {
 # Internal logging function, don't use this in ebuilds
 __elog_base() {
        local messagetype
-       [ -z "${1}" -o -z "${T}" -o ! -d "${T}/logging" ] && return 1
+       [[ -z "${1}" || -z "${T}" || ! -d "${T}/logging" ]] && return 1
        case "${1}" in
                INFO|WARN|ERROR|LOG|QA)
                        messagetype="${1}"
@@ -429,7 +429,7 @@ __set_colors() {
        # Now, ${ENDCOL} will move us to the end of the
        # column;  irregardless of character width
        ENDCOL=$'\e[A\e['$(( COLS - 8 ))'C'
-       if [ -n "${PORTAGE_COLORMAP}" ] ; then
+       if [[ -n "${PORTAGE_COLORMAP}" ]]; then
                eval ${PORTAGE_COLORMAP}
        else
                PORTAGE_COLOR_BAD=$'\e[31;01m'
@@ -531,7 +531,7 @@ has() {
 
        local x
        for x in "$@"; do
-               [ "${x}" = "${needle}" ] && return 0
+               [[ "${x}" = "${needle}" ]] && return 0
        done
        return 1
 }

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index de7ebf4a2..41340e3f7 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -22,16 +22,16 @@ install_symlink_html_docs() {
        fi
        cd "${ED}" || die "cd failed"
        # Symlink the html documentation (if DOC_SYMLINKS_DIR is set in 
make.conf)
-       if [ -n "${DOC_SYMLINKS_DIR}" ] ; then
+       if [[ -n "${DOC_SYMLINKS_DIR}" ]]; then
                local mydocdir docdir
                for docdir in "${HTMLDOC_DIR:-does/not/exist}" "${PF}/html" 
"${PF}/HTML" "${P}/html" "${P}/HTML" ; do
-                       if [ -d "usr/share/doc/${docdir}" ] ; then
+                       if [[ -d "usr/share/doc/${docdir}" ]]; then
                                mydocdir="/usr/share/doc/${docdir}"
                        fi
                done
-               if [ -n "${mydocdir}" ] ; then
+               if [[ -n "${mydocdir}" ]]; then
                        local mysympath
-                       if [ -z "${SLOT}" -o "${SLOT%/*}" = "0" ] ; then
+                       if [[ -z "${SLOT}" || "${SLOT%/*}" = "0" ]]; then
                                
mysympath="${DOC_SYMLINKS_DIR}/${CATEGORY}/${PN}"
                        else
                                
mysympath="${DOC_SYMLINKS_DIR}/${CATEGORY}/${PN}-${SLOT%/*}"
@@ -206,7 +206,7 @@ install_qa_check() {
                                arch=${l%%;*}; l=${l#*;}
                                obj="/${l%%;*}"; l=${l#*;}
                                soname=${l%%;*}; l=${l#*;}
-                               rpath=${l%%;*}; l=${l#*;}; [ "${rpath}" = "  -  
" ] && rpath=""
+                               rpath=${l%%;*}; l=${l#*;}; [[ "${rpath}" = "  - 
 " ]] && rpath=""
                                needed=${l%%;*}; l=${l#*;}
 
                                # Infer implicit soname from basename (bug 
715162).
@@ -219,7 +219,7 @@ install_qa_check() {
                        done <<< ${scanelf_output}
                fi
 
-               [ -n "${QA_SONAME_NO_SYMLINK}" ] && \
+               [[ -n "${QA_SONAME_NO_SYMLINK}" ]] && \
                        echo "${QA_SONAME_NO_SYMLINK}" > \
                        "${PORTAGE_BUILDDIR}"/build-info/QA_SONAME_NO_SYMLINK
 
@@ -384,7 +384,7 @@ preinst_mask() {
 }
 
 preinst_sfperms() {
-       if [ -z "${D}" ]; then
+       if [[ -z "${D}" ]]; then
                 eerror "${FUNCNAME}: D is unset"
                 return 1
        fi
@@ -398,7 +398,7 @@ preinst_sfperms() {
                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"
                                eend $?
@@ -410,7 +410,7 @@ preinst_sfperms() {
                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
@@ -424,7 +424,7 @@ preinst_sfperms() {
 }
 
 preinst_suid_scan() {
-       if [ -z "${D}" ]; then
+       if [[ -z "${D}" ]]; then
                 eerror "${FUNCNAME}: D is unset"
                 return 1
        fi
@@ -443,7 +443,7 @@ preinst_suid_scan() {
                addwrite "${sfconf}"
                __vecho ">>> Performing suid scan in ${ED}"
                for i in $(find "${ED}" -type f \( -perm -4000 -o -perm -2000 
\) ); do
-                       if [ -s "${sfconf}" ]; then
+                       if [[ -s "${sfconf}" ]]; then
                                install_path=${i#${ED%/}}
                                if grep -q "^${install_path}\$" "${sfconf}" ; 
then
                                        __vecho "- ${install_path} is an 
approved suid file"
@@ -468,7 +468,7 @@ preinst_suid_scan() {
 }
 
 preinst_selinux_labels() {
-       if [ -z "${D}" ]; then
+       if [[ -z "${D}" ]]; then
                 eerror "${FUNCNAME}: D is unset"
                 return 1
        fi
@@ -476,7 +476,7 @@ preinst_selinux_labels() {
                # SELinux file labeling (needs to execute after preinst)
                # only attempt to label if setfiles is executable
                # and 'context' is available on selinuxfs.
-               if [ -f /sys/fs/selinux/context -a -x /usr/sbin/setfiles -a -x 
/usr/sbin/selinuxconfig ]; then
+               if [[ -f /sys/fs/selinux/context && -x /usr/sbin/setfiles && -x 
/usr/sbin/selinuxconfig ]]; then
                        __vecho ">>> Setting SELinux security labels"
                        (
                                eval "$(/usr/sbin/selinuxconfig)" || \
@@ -633,7 +633,7 @@ install_hooks() {
        local ret=0
        shopt -s nullglob
        for fp in "${hooks_dir}"/*; do
-               if [ -x "$fp" ]; then
+               if [[ -x "$fp" ]]; then
                        "$fp"
                        ret=$(( $ret | $? ))
                fi
@@ -646,9 +646,9 @@ eqatag() {
        __eqatag "${@}"
 }
 
-if [ -n "${MISC_FUNCTIONS_ARGS}" ]; then
+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

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index 6b48c2351..5aba2519c 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -136,7 +136,7 @@ __filter_readonly_variables() {
                        LC_NUMERIC LC_PAPER LC_TIME"
        fi
        if ! has --allow-extra-vars $* ; then
-               if [ "${EMERGE_FROM}" = binary ] ; then
+               if [[ "${EMERGE_FROM}" = binary ]]; then
                        # preserve additional variables from build time,
                        # while excluding untrusted variables
                        filtered_vars+=" ${binpkg_untrusted_vars}"
@@ -163,7 +163,7 @@ __preprocess_ebuild_env() {
        # indicating that the environment may contain stale FEATURES and
        # SANDBOX_{DENY,PREDICT,READ,WRITE} variables that should be filtered 
out.
        # Otherwise, we don't need to filter the environment.
-       [ -f "${T}/environment.raw" ] || return 0
+       [[ -f "${T}/environment.raw" ]] || return 0
 
        __filter_readonly_variables $_portage_filter_opts < "${T}"/environment \
                >> "$T/environment.filtered" || return $?
@@ -195,7 +195,7 @@ __preprocess_ebuild_env() {
                >> "$T/environment.success" || exit $?
        ) > "${T}/environment.filtered"
        local retval
-       if [ -e "${T}/environment.success" ] ; then
+       if [[ -e "${T}/environment.success" ]]; then
                __filter_readonly_variables --filter-features < \
                        "${T}/environment.filtered" > "${T}/environment"
                retval=$?
@@ -248,7 +248,7 @@ __dyn_unpack() {
                __vecho ">>> WORKDIR is up-to-date, keeping..."
                return 0
        fi
-       if [ ! -d "${WORKDIR}" ]; then
+       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}'\`"
@@ -262,10 +262,10 @@ __dyn_unpack() {
 }
 
 __dyn_clean() {
-       if [ -z "${PORTAGE_BUILDDIR}" ]; then
+       if [[ -z "${PORTAGE_BUILDDIR}" ]]; then
                echo "Aborting clean phase because PORTAGE_BUILDDIR is unset!"
                return 1
-       elif [ ! -d "${PORTAGE_BUILDDIR}" ] ; then
+       elif [[ ! -d "${PORTAGE_BUILDDIR}" ]]; then
                return 0
        fi
        if has chflags $FEATURES ; then
@@ -299,7 +299,7 @@ __dyn_clean() {
                rm -f "${PORTAGE_BUILDDIR}/files"
        fi
 
-       if [ -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then
+       if [[ -f "${PORTAGE_BUILDDIR}/.unpacked" ]]; then
                find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | 
sort -r | tr "\n" "\0" | $XARGS -0 rmdir &>/dev/null
        fi
 
@@ -314,7 +314,7 @@ __dyn_clean() {
 
 __abort_handler() {
        local msg
-       if [ "$2" != "fail" ]; then
+       if [[ "$2" != "fail" ]]; then
                msg="${EBUILD}: ${1} aborted; exiting."
        else
                msg="${EBUILD}: ${1} failed; exiting."
@@ -519,7 +519,7 @@ __dyn_test() {
 }
 
 __dyn_install() {
-       [ -z "$PORTAGE_BUILDDIR" ] && die "${FUNCNAME}: PORTAGE_BUILDDIR is 
unset"
+       [[ -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
@@ -703,7 +703,7 @@ __dyn_install() {
        ${PORTAGE_BZIP2_COMMAND} -f9 environment
 
        cp "${EBUILD}" "${PF}.ebuild"
-       [ -n "${PORTAGE_REPO_NAME}" ]  && echo "${PORTAGE_REPO_NAME}" > 
repository
+       [[ -n "${PORTAGE_REPO_NAME}" ]]  && echo "${PORTAGE_REPO_NAME}" > 
repository
        if has nostrip ${FEATURES} ${PORTAGE_RESTRICT} || has strip 
${PORTAGE_RESTRICT}
        then
                >> DEBUGBUILD
@@ -767,7 +767,7 @@ __dyn_help() {
        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}"
@@ -780,7 +780,7 @@ __dyn_help() {
 # Translate a known ebuild(1) argument into the precise
 # name of it's corresponding ebuild phase.
 __ebuild_arg_to_phase() {
-       [ $# -ne 1 ] && die "expected exactly 1 arg, got $#: $*"
+       [[ $# -ne 1 ]] && die "expected exactly 1 arg, got $#: $*"
        local arg=$1
        local phase_func=""
 
@@ -835,7 +835,7 @@ __ebuild_arg_to_phase() {
 }
 
 __ebuild_phase_funcs() {
-       [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*"
+       [[ $# -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
@@ -988,7 +988,7 @@ __ebuild_main() {
                        ewarn  "pkg_${1}() is not defined: '${EBUILD##*/}'"
                fi
                export SANDBOX_ON="0"
-               if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
+               if [[ "${PORTAGE_DEBUG}" != "1" ]] || [[ "${-/x/}" != "$-" ]]; 
then
                        __ebuild_phase_with_hooks pkg_${1}
                else
                        set -x
@@ -1043,7 +1043,7 @@ __ebuild_main() {
                        fi
 
                        cd "$PORTAGE_BUILDDIR"
-                       if [ ! -d build-info ] ; then
+                       if [[ ! -d build-info ]]; then
                                mkdir build-info
                                cp "$EBUILD" "build-info/$PF.ebuild"
                        fi
@@ -1055,7 +1055,7 @@ __ebuild_main() {
                        ;;
                esac
 
-               if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
+               if [[ "${PORTAGE_DEBUG}" != "1" ]] || [[ "${-/x/}" != "$-" ]]; 
then
                        __dyn_${1}
                else
                        set -x
@@ -1069,7 +1069,7 @@ __ebuild_main() {
                #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
+               if [[ "${PORTAGE_DEBUG}" != "1" ]] || [[ "${-/x/}" != "$-" ]]; 
then
                        __dyn_${1}
                else
                        set -x

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index cbe0b825d..64c168627 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -25,14 +25,14 @@ has strip ${PORTAGE_RESTRICT} && PORTAGE_DOSTRIP=()
 declare -a PORTAGE_DOSTRIP_SKIP=()
 
 into() {
-       if [ "$1" == "/" ]; then
+       if [[ "$1" == "/" ]]; then
                export _E_DESTTREE_=""
        else
                export _E_DESTTREE_=$1
                if ! ___eapi_has_prefix_variables; then
                        local ED=${D}
                fi
-               if [ ! -d "${ED%/}/${_E_DESTTREE_#/}" ]; then
+               if [[ ! -d "${ED%/}/${_E_DESTTREE_#/}" ]]; then
                        install -d "${ED%/}/${_E_DESTTREE_#/}"
                        local ret=$?
                        if [[ $ret -ne 0 ]] ; then
@@ -48,14 +48,14 @@ into() {
 }
 
 insinto() {
-       if [ "$1" == "/" ]; then
+       if [[ "$1" == "/" ]]; then
                export _E_INSDESTTREE_=""
        else
                export _E_INSDESTTREE_=$1
                if ! ___eapi_has_prefix_variables; then
                        local ED=${D}
                fi
-               if [ ! -d "${ED%/}/${_E_INSDESTTREE_#/}" ]; then
+               if [[ ! -d "${ED%/}/${_E_INSDESTTREE_#/}" ]]; then
                        install -d "${ED%/}/${_E_INSDESTTREE_#/}"
                        local ret=$?
                        if [[ $ret -ne 0 ]] ; then
@@ -71,14 +71,14 @@ insinto() {
 }
 
 exeinto() {
-       if [ "$1" == "/" ]; then
+       if [[ "$1" == "/" ]]; then
                export _E_EXEDESTTREE_=""
        else
                export _E_EXEDESTTREE_="$1"
                if ! ___eapi_has_prefix_variables; then
                        local ED=${D}
                fi
-               if [ ! -d "${ED%/}/${_E_EXEDESTTREE_#/}" ]; then
+               if [[ ! -d "${ED%/}/${_E_EXEDESTTREE_#/}" ]]; then
                        install -d "${ED%/}/${_E_EXEDESTTREE_#/}"
                        local ret=$?
                        if [[ $ret -ne 0 ]] ; then
@@ -90,14 +90,14 @@ exeinto() {
 }
 
 docinto() {
-       if [ "$1" == "/" ]; then
+       if [[ "$1" == "/" ]]; then
                export _E_DOCDESTTREE_=""
        else
                export _E_DOCDESTTREE_="$1"
                if ! ___eapi_has_prefix_variables; then
                        local ED=${D}
                fi
-               if [ ! -d "${ED%/}/usr/share/doc/${PF}/${_E_DOCDESTTREE_#/}" ]; 
then
+               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
@@ -268,7 +268,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
@@ -290,7 +290,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
@@ -318,7 +318,7 @@ unpack() {
        local suffix suffix_insensitive
        local myfail
        local eapi=${EAPI:-0}
-       [ -z "$*" ] && die "Nothing passed to the 'unpack' command"
+       [[ -z "$*" ]] && die "Nothing passed to the 'unpack' command"
 
        for x in "$@"; do
                __vecho ">>> Unpacking ${x} to ${PWD}"
@@ -436,7 +436,7 @@ unpack() {
                                if ___eapi_unpack_supports_7z; then
                                        local my_output
                                        my_output="$(7z x -y "${srcdir}${x}")"
-                                       if [ $? -ne 0 ]; then
+                                       if [[ $? -ne 0 ]]; then
                                                echo "${my_output}" >&2
                                                die "$myfail"
                                        fi
@@ -497,7 +497,7 @@ 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.
@@ -505,7 +505,7 @@ unpack() {
                                                created_symlink=1
                                        fi
                                        deb2targz "$y" || die "$myfail"
-                                       if [ $created_symlink = 1 ] ; then
+                                       if [[ $created_symlink = 1 ]]; then
                                                # Clean up the symlink so the 
ebuild
                                                # doesn't inadvertently install 
it.
                                                rm -f "$y"
@@ -594,7 +594,7 @@ econf() {
        fi
 
        : ${ECONF_SOURCE:=.}
-       if [ -x "${ECONF_SOURCE}/configure" ]; then
+       if [[ -x "${ECONF_SOURCE}/configure" ]]; 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
@@ -606,7 +606,7 @@ econf() {
                        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
+               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
@@ -701,7 +701,7 @@ econf() {
 
                if ! "${ECONF_SOURCE}/configure" "$@" ; then
 
-                       if [ -s config.log ]; then
+                       if [[ -s config.log ]]; then
                                echo
                                echo "!!! Please attach the following file when 
seeking support:"
                                echo "!!! ${PWD}/config.log"
@@ -711,7 +711,7 @@ econf() {
                        __helpers_die "econf failed"
                        return 1
                fi
-       elif [ -f "${ECONF_SOURCE}/configure" ]; then
+       elif [[ -f "${ECONF_SOURCE}/configure" ]]; then
                die "configure is not executable"
        else
                die "no configure script found"
@@ -730,11 +730,11 @@ einstall() {
                local ED=${D}
        fi
        LIBDIR_VAR="LIBDIR_${ABI}"
-       if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
+       if [[ -n "${ABI}" && -n "${!LIBDIR_VAR}" ]]; then
                CONF_LIBDIR="${!LIBDIR_VAR}"
        fi
        unset LIBDIR_VAR
-       if [ -n "${CONF_LIBDIR}" ] && [ "${CONF_PREFIX:+set}" = set ]; then
+       if [[ -n "${CONF_LIBDIR}" && "${CONF_PREFIX:+set}" = set ]]; then
                EI_DESTLIBDIR="${D%/}/${CONF_PREFIX}/${CONF_LIBDIR}"
                EI_DESTLIBDIR="$(__strip_duplicate_slashes "${EI_DESTLIBDIR}")"
                LOCAL_EXTRA_EINSTALL="libdir=${EI_DESTLIBDIR} 
${LOCAL_EXTRA_EINSTALL}"
@@ -742,7 +742,7 @@ einstall() {
        fi
 
        if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then
-               if [ "${PORTAGE_DEBUG}" == "1" ]; then
+               if [[ "${PORTAGE_DEBUG}" == "1" ]]; then
                        ${MAKE:-make} -n prefix="${ED%/}/usr" \
                                datadir="${ED%/}/usr/share" \
                                infodir="${ED%/}/usr/share/info" \
@@ -786,7 +786,7 @@ __eapi0_src_unpack() {
 }
 
 __eapi0_src_compile() {
-       if [ -x ./configure ] ; then
+       if [[ -x ./configure ]]; then
                econf
        fi
        __eapi2_src_compile
@@ -830,7 +830,7 @@ __eapi2_src_configure() {
 }
 
 __eapi2_src_compile() {
-       if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then
+       if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
                emake || die "emake failed"
        fi
 }
@@ -892,7 +892,7 @@ ___best_version_and_has_version_common() {
        esac
        atom=$1
        shift
-       [ $# -gt 0 ] && die "${FUNCNAME[1]}: unused argument(s): $*"
+       [[ $# -gt 0 ]] && die "${FUNCNAME[1]}: unused argument(s): $*"
 
        case ${root_arg} in
                "") if ___eapi_has_prefix_variables; then

Reply via email to