commit:     64edea29f6e62c0ac1005d072f391fe5d4dc0822
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 26 11:16:13 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Aug 26 11:16:13 2017 +0000
URL:        https://gitweb.gentoo.org/proj/elt-patches.git/commit/?id=64edea29

Use explicit tool vars instead of aliases

Aliases do not work for calling the tool in a subshell, so just
explicitly set FIND, PATCH and SED variables to the correct tool,
and use them to call them.

 eltpatch.in | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/eltpatch.in b/eltpatch.in
index 8f6f9f3..d8c847b 100644
--- a/eltpatch.in
+++ b/eltpatch.in
@@ -3,10 +3,9 @@
 # Distributed under the terms of the GNU General Public License v2
 
 # BSD support; https://bugs.gentoo.org/628882
-# note: this need to happen before function definitions
-type -P gfind &>/dev/null && alias find=gfind
-type -P gpatch &>/dev/null && alias patch=gpatch
-type -P gsed &>/dev/null && alias sed=gsed
+type -P gfind &>/dev/null && FIND=gfind || FIND=find
+type -P gpatch &>/dev/null && PATCH=gpatch || PATCH=patch
+type -P gsed &>/dev/null && SED=gsed || SED=sed
 
 source "@ELT_gentoofuncs@" || exit 1
 
@@ -40,11 +39,11 @@ ELT_try_and_apply_patch() {
        # Save file for permission restoration.  `patch` sometimes resets 
things.
        # Ideally we'd want 'stat -c %a', but stat is highly non portable and 
we are
        # guaranted to have GNU find, so use that instead.
-       local perms="$(find ${file} -maxdepth 0 -printf '%m')"
+       local perms="$(${FIND} ${file} -maxdepth 0 -printf '%m')"
        # We only support patchlevel of 0 - why worry if its static patches?
-       if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
+       if ${PATCH} -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1 ; then
                einfo "  Applying ${disp} ..."
-               patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> 
"${log}" 2>&1
+               ${PATCH} -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" 
>> "${log}" 2>&1
                ret=$?
                ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}"
        else
@@ -92,9 +91,9 @@ ELT_walk_patches() {
        pushd "@ELT_patchdir@" >/dev/null || die "pushd to elt-patch dir failed"
 
        # Go through the patches in reverse order (newer version to older)
-       for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort 
-r) ; do
+       for patch in $(${FIND} "${patch_set}" -maxdepth 1 -type f | LC_ALL=C 
sort -r) ; do
                tmp="${TMPDIR}/libtool-elt.patch"
-               sed "${sed_args[@]}" "${patch}" > "${tmp}" || die "sed on patch 
${patch} failed"
+               ${SED} "${sed_args[@]}" "${patch}" > "${tmp}" || die "sed on 
patch ${patch} failed"
                if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}" ; then
                        # Break to unwind w/popd rather than return directly
                        ret=0
@@ -192,7 +191,7 @@ elibtoolize() {
                [[ -f ${S}/ltmain.sh || -f ${S}/configure ]] && dirs+=( "${S}" )
        else
                [[ ${#dirs[@]} -eq 0 ]] && dirs+=( "${S}" )
-               dirs=( $(find "${dirs[@]}" '(' -name ltmain.sh -o -name 
configure ')' -printf '%h\n' | sort -u) )
+               dirs=( $(${FIND} "${dirs[@]}" '(' -name ltmain.sh -o -name 
configure ')' -printf '%h\n' | sort -u) )
        fi
 
        local d p ret

Reply via email to