Re: [PATCH 15/20] t/lib-t6000: refactor `name_from_description()` to not depend on Perl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 20, 2025 at 03:41:11PM -0400, Eric Sunshine wrote:
> On Thu, Mar 20, 2025 at 5:37 AM Patrick Steinhardt <ps@xxxxxx> wrote:
> > The `name_from_description()` test helper uses Perl to munge a given
> > description and convert it into a name. Refactor it to instead use a
> > combination of sed(1) and tr(1) so that we drop PERL_TEST_HELPERS
> > prerequisites in users of this library.
> >
> > Signed-off-by: Patrick Steinhardt <ps@xxxxxx>
> > ---
> > diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh
> > @@ -109,13 +109,12 @@ check_output () {
> >  # All alphanums translated into -'s which are then compressed and stripped
> >  # from front and back.
> >  name_from_description () {
> > -       perl -pe '
> > -               s/[^A-Za-z0-9.]/-/g;
> > -               s/-+/-/g;
> > -               s/-$//;
> > -               s/^-//;
> > -               y/A-Z/a-z/;
> > -       '
> > +       sed \
> > +               -e 's/[^A-Za-z0-9.]/-/g' \
> > +               -e 's/--*/-/g' \
> > +               -e 's/-$//' \
> > +               -e 's/^-//' |
> > +       tr 'A-Z' 'a-z'
> >  }
> 
> Can't you just use sed's `y//` function directly instead of having to
> separately invoke a `tr` command?

Ah, of course, will change!

Patrick




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux