public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: James Le Cuirot <chewi@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call in python_fix_shebang
Date: Sat, 15 Sep 2018 22:51:28 +0100	[thread overview]
Message-ID: <20180915225128.5e560b81@symphony.aura-online.co.uk> (raw)
In-Reply-To: <1537021648.30445.0.camel@gentoo.org>

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]

On Sat, 15 Sep 2018 16:27:28 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> On Fri, 2018-09-14 at 23:44 +0100, James Le Cuirot wrote:
> > There's no need for two separate sed calls here.
> > ---
> >  eclass/python-utils-r1.eclass | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> > index e3cf82b4b58f..121f2382ba78 100644
> > --- a/eclass/python-utils-r1.eclass
> > +++ b/eclass/python-utils-r1.eclass
> > @@ -1247,11 +1247,7 @@ python_fix_shebang() {
> >  			if [[ ! ${error} ]]; then
> >  				# We either want to match ${from} followed by space
> >  				# or at end-of-string.
> > -				if [[ ${shebang} == *${from}" "* ]]; then
> > -					sed -i -e "1s:${from} :${EPYTHON} :" "${f}" || die
> > -				else
> > -					sed -i -e "1s:${from}$:${EPYTHON}:" "${f}" || die
> > -				fi
> > +				sed -i -e "1s:${from}\( \|\$\):${EPYTHON}\1:" "${f}" || die  
> 
> Hmm, I wonder if we could just utilize '\b' here.

I also considered it but that would match /, which is no good. For
example, it would replace python in /usr/python/foo.

I am now working on a new approach to better accommodate my cross stuff
that would supersede this anyway but it's not ready yet.

> >  				any_fixed=1
> >  			else
> >  				eerror "The file has incompatible shebang:"  

-- 
James Le Cuirot (chewi)
Gentoo Linux Developer

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 981 bytes --]

      reply	other threads:[~2018-09-15 21:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 22:44 [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call in python_fix_shebang James Le Cuirot
2018-09-14 22:44 ` [gentoo-dev] [PATCH 2/2] python-utils-r1.eclass: Fix all correct check " James Le Cuirot
2018-09-15 14:27 ` [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call " Michał Górny
2018-09-15 21:51   ` James Le Cuirot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180915225128.5e560b81@symphony.aura-online.co.uk \
    --to=chewi@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox