Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] eutils.eclass: make_wrapper, fix 'cd' error handling
Date: Fri, 22 Jun 2018 08:43:03
Message-Id: 20180622084250.31849-1-mgorny@gentoo.org
1 Reorder the generated wrapper, and add '&&' after the 'cd' call so that
2 the wrapper will not try to execute the program if 'cd' command fails.
3 ---
4 eclass/eutils.eclass | 2 +-
5 1 file changed, 1 insertion(+), 1 deletion(-)
6
7 diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
8 index 81621df78e63..9b4767e1874a 100644
9 --- a/eclass/eutils.eclass
10 +++ b/eclass/eutils.eclass
11 @@ -148,7 +148,6 @@ make_wrapper() {
12
13 (
14 echo '#!/bin/sh'
15 - [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}"
16 if [[ -n ${libdir} ]] ; then
17 local var
18 if [[ ${CHOST} == *-darwin* ]] ; then
19 @@ -164,6 +163,7 @@ make_wrapper() {
20 fi
21 EOF
22 fi
23 + [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}"
24 # We don't want to quote ${bin} so that people can pass complex
25 # things as ${bin} ... "./someprog --args"
26 printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}"
27 --
28 2.18.0.rc2