public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call in python_fix_shebang
@ 2018-09-14 22:44 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
  0 siblings, 2 replies; 4+ messages in thread
From: James Le Cuirot @ 2018-09-14 22:44 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, James Le Cuirot

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
 				any_fixed=1
 			else
 				eerror "The file has incompatible shebang:"
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 2/2] python-utils-r1.eclass: Fix all correct check in python_fix_shebang
  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 ` James Le Cuirot
  2018-09-15 14:27 ` [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call " Michał Górny
  1 sibling, 0 replies; 4+ messages in thread
From: James Le Cuirot @ 2018-09-14 22:44 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, James Le Cuirot

When matching EPYTHON, it would previously call sed and set
any_fixed=1 even though it was already correct. If all are correct, it
is supposed to raise a QA warning/error.
---
 eclass/python-utils-r1.eclass | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 121f2382ba78..f93235e3f5f4 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1187,8 +1187,7 @@ python_fix_shebang() {
 
 							# Nothing to do, move along.
 							any_correct=1
-							from=${EPYTHON}
-							break
+							continue 2
 							;;
 						*python|*python[23])
 							debug-print "${FUNCNAME}: in file ${f#${D%/}}"
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call in python_fix_shebang
  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 ` Michał Górny
  2018-09-15 21:51   ` James Le Cuirot
  1 sibling, 1 reply; 4+ messages in thread
From: Michał Górny @ 2018-09-15 14:27 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, James Le Cuirot

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

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.

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

-- 
Best regards,
Michał Górny

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: Simplify sed call in python_fix_shebang
  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
  0 siblings, 0 replies; 4+ messages in thread
From: James Le Cuirot @ 2018-09-15 21:51 UTC (permalink / raw
  To: gentoo-dev

[-- 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 --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-15 21:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox