Patchwork solaris: solaris grep doesn't have -A; reimplement with awk

login
register
mail settings
Submitter Danek Duvall
Date June 2, 2017, 11:20 p.m.
Message ID <d41ec8a079648101eae9.1496445606@smelly>
Download mbox | patch
Permalink /patch/21144/
State Changes Requested
Headers show

Comments

Danek Duvall - June 2, 2017, 11:20 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1496445527 25200
#      Fri Jun 02 16:18:47 2017 -0700
# Node ID d41ec8a079648101eae94a25e05c6d7a7b26b653
# Parent  e6ff007e107e434b35eb881711f459c7a75c91b2
solaris: solaris grep doesn't have -A; reimplement with awk
Yuya Nishihara - June 3, 2017, 3:39 a.m.
On Fri, 02 Jun 2017 16:20:06 -0700, danek.duvall@oracle.com wrote:
> # HG changeset patch
> # User Danek Duvall <danek.duvall@oracle.com>
> # Date 1496445527 25200
> #      Fri Jun 02 16:18:47 2017 -0700
> # Node ID d41ec8a079648101eae94a25e05c6d7a7b26b653
> # Parent  e6ff007e107e434b35eb881711f459c7a75c91b2
> solaris: solaris grep doesn't have -A; reimplement with awk
> 
> diff --git a/tests/test-obsolete-bundle-strip.t b/tests/test-obsolete-bundle-strip.t
> --- a/tests/test-obsolete-bundle-strip.t
> +++ b/tests/test-obsolete-bundle-strip.t
> @@ -67,7 +67,7 @@ obsmarkers.
>    >     cat "${markersfile}"
>    >     printf "# bundling: "
>    >     hg bundle --hidden --base "parents(roots(${revs}))" --rev "${revs}" "${bundlefile}"
> -  >     hg debugbundle "${bundlefile}" | grep "obsmarkers --" -A 100 | sed 1,2d > "${contentfile}"
> +  >     hg debugbundle "${bundlefile}" | awk '/obsmarkers --/ {p=1} p == 1 {print}' | sed 1,2d > "${contentfile}"

awk is new dependency. Can't we add an option to filter debugbundle output
(e.g. "hg debugbundle --part-type obsmarkers")?
Pierre-Yves David - June 3, 2017, 8:28 a.m.
On 06/03/2017 01:20 AM, danek.duvall@oracle.com wrote:
> # HG changeset patch
> # User Danek Duvall <danek.duvall@oracle.com>
> # Date 1496445527 25200
> #      Fri Jun 02 16:18:47 2017 -0700
> # Node ID d41ec8a079648101eae94a25e05c6d7a7b26b653
> # Parent  e6ff007e107e434b35eb881711f459c7a75c91b2
> solaris: solaris grep doesn't have -A; reimplement with awk

We should probably get a check-code rules for this.

Cheers,
Danek Duvall - June 5, 2017, 11:33 p.m.
Yuya Nishihara wrote:

> On Fri, 02 Jun 2017 16:20:06 -0700, danek.duvall@oracle.com wrote:
> > # HG changeset patch
> > # User Danek Duvall <danek.duvall@oracle.com>
> > # Date 1496445527 25200
> > #      Fri Jun 02 16:18:47 2017 -0700
> > # Node ID d41ec8a079648101eae94a25e05c6d7a7b26b653
> > # Parent  e6ff007e107e434b35eb881711f459c7a75c91b2
> > solaris: solaris grep doesn't have -A; reimplement with awk
> > 
> > diff --git a/tests/test-obsolete-bundle-strip.t b/tests/test-obsolete-bundle-strip.t
> > --- a/tests/test-obsolete-bundle-strip.t
> > +++ b/tests/test-obsolete-bundle-strip.t
> > @@ -67,7 +67,7 @@ obsmarkers.
> >    >     cat "${markersfile}"
> >    >     printf "# bundling: "
> >    >     hg bundle --hidden --base "parents(roots(${revs}))" --rev "${revs}" "${bundlefile}"
> > -  >     hg debugbundle "${bundlefile}" | grep "obsmarkers --" -A 100 | sed 1,2d > "${contentfile}"
> > +  >     hg debugbundle "${bundlefile}" | awk '/obsmarkers --/ {p=1} p == 1 {print}' | sed 1,2d > "${contentfile}"
> 
> awk is new dependency. Can't we add an option to filter debugbundle output
> (e.g. "hg debugbundle --part-type obsmarkers")?

Okay, coming up.

Thanks,
Danek
Danek Duvall - June 5, 2017, 11:36 p.m.
Pierre-Yves David wrote:

> 
> 
> On 06/03/2017 01:20 AM, danek.duvall@oracle.com wrote:
> ># HG changeset patch
> ># User Danek Duvall <danek.duvall@oracle.com>
> ># Date 1496445527 25200
> >#      Fri Jun 02 16:18:47 2017 -0700
> ># Node ID d41ec8a079648101eae94a25e05c6d7a7b26b653
> ># Parent  e6ff007e107e434b35eb881711f459c7a75c91b2
> >solaris: solaris grep doesn't have -A; reimplement with awk
> 
> We should probably get a check-code rules for this.

Given that there's no consistent replacement for it, I'm a bit uncertain.
Adding a flag to a command makes sense in this case, but maybe not always
in the future.

I'm happy to add the check, though, if folks think it's the right path
forward.  I assume that -B and -C should come along for the ride?

Danek
Augie Fackler - June 6, 2017, 2:57 a.m.
> On Jun 5, 2017, at 7:36 PM, Danek Duvall <danek.duvall@oracle.com> wrote:
> 
> Pierre-Yves David wrote:
> 
>> 
>> 
>> On 06/03/2017 01:20 AM, danek.duvall@oracle.com wrote:
>>> # HG changeset patch
>>> # User Danek Duvall <danek.duvall@oracle.com>
>>> # Date 1496445527 25200
>>> #      Fri Jun 02 16:18:47 2017 -0700
>>> # Node ID d41ec8a079648101eae94a25e05c6d7a7b26b653
>>> # Parent  e6ff007e107e434b35eb881711f459c7a75c91b2
>>> solaris: solaris grep doesn't have -A; reimplement with awk
>> 
>> We should probably get a check-code rules for this.
> 
> Given that there's no consistent replacement for it, I'm a bit uncertain.
> Adding a flag to a command makes sense in this case, but maybe not always
> in the future.
> 
> I'm happy to add the check, though, if folks think it's the right path
> forward.  I assume that -B and -C should come along for the ride?

Yep, (I’m assuming since you asked solaris grep is also sad about those flags.)

> 
> Danek
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Danek Duvall - June 6, 2017, 3:52 p.m.
Augie Fackler wrote:

> > I'm happy to add the check, though, if folks think it's the right path
> > forward.  I assume that -B and -C should come along for the ride?
> 
> Yep, (I’m assuming since you asked solaris grep is also sad about those flags.)

Solaris grep is sad about many flags.  Except --get-off-my-lawn.

Danek

Patch

diff --git a/tests/test-obsolete-bundle-strip.t b/tests/test-obsolete-bundle-strip.t
--- a/tests/test-obsolete-bundle-strip.t
+++ b/tests/test-obsolete-bundle-strip.t
@@ -67,7 +67,7 @@  obsmarkers.
   >     cat "${markersfile}"
   >     printf "# bundling: "
   >     hg bundle --hidden --base "parents(roots(${revs}))" --rev "${revs}" "${bundlefile}"
-  >     hg debugbundle "${bundlefile}" | grep "obsmarkers --" -A 100 | sed 1,2d > "${contentfile}"
+  >     hg debugbundle "${bundlefile}" | awk '/obsmarkers --/ {p=1} p == 1 {print}' | sed 1,2d > "${contentfile}"
   >     echo '### Bundled markers ###'
   >     cat "${contentfile}"
   >     echo '### diff <relevant> <bundled> ###'