commit:     bef50010a4899db1896133fad0d6ca1d387b6ec2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 22 08:42:03 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Jul 16 20:51:41 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bef50010

eutils.eclass: make_wrapper, fix 'cd' error handling

Reorder the generated wrapper, and add '&&' after the 'cd' call so that
the wrapper will not try to execute the program if 'cd' command fails.

 eclass/eutils.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index 81621df78e6..9b4767e1874 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -148,7 +148,6 @@ make_wrapper() {
 
        (
        echo '#!/bin/sh'
-       [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}"
        if [[ -n ${libdir} ]] ; then
                local var
                if [[ ${CHOST} == *-darwin* ]] ; then
@@ -164,6 +163,7 @@ make_wrapper() {
                        fi
                EOF
        fi
+       [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}"
        # We don't want to quote ${bin} so that people can pass complex
        # things as ${bin} ... "./someprog --args"
        printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}"

Reply via email to