eutils.eclass: make_wrapper, fix 'cd' error handling
authorMichał Górny <mgorny@gentoo.org>
Fri, 22 Jun 2018 08:42:03 +0000 (10:42 +0200)
committerMichał Górny <mgorny@gentoo.org>
Mon, 16 Jul 2018 20:51:41 +0000 (22:51 +0200)
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

index 81621df78e63ee126a3b334d9ef7a3e91d000bf5..9b4767e1874af58b390bf2df1e77fcbb786c3a80 100644 (file)
@@ -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}/}"