Gentoo Archives: gentoo-dev

From: James Le Cuirot <chewi@g.o>
To: gentoo-dev@l.g.o
Cc: python@g.o, James Le Cuirot <chewi@g.o>
Subject: [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call in python_fix_shebang
Date: Fri, 14 Sep 2018 22:44:55
Message-Id: 20180914224438.29404-1-chewi@gentoo.org
1 There's no need for two separate sed calls here.
2 ---
3 eclass/python-utils-r1.eclass | 6 +-----
4 1 file changed, 1 insertion(+), 5 deletions(-)
5
6 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
7 index e3cf82b4b58f..121f2382ba78 100644
8 --- a/eclass/python-utils-r1.eclass
9 +++ b/eclass/python-utils-r1.eclass
10 @@ -1247,11 +1247,7 @@ python_fix_shebang() {
11 if [[ ! ${error} ]]; then
12 # We either want to match ${from} followed by space
13 # or at end-of-string.
14 - if [[ ${shebang} == *${from}" "* ]]; then
15 - sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die
16 - else
17 - sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die
18 - fi
19 + sed -i -e "1s:${from}\( \|\$\):${EPYTHON}\1:" "${f}" || die
20 any_fixed=1
21 else
22 eerror "The file has incompatible shebang:"
23 --
24 2.18.0

Replies