All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Robbie Harwood <rharwood@redhat.com>
Cc: Daniel Kiper <daniel.kiper@oracle.com>,
	 Vladimir phcoder Serbinenko <phcoder@gmail.com>,
	 grub-devel <grub-devel@gnu.org>,
	Paul Menzel <pmenzel@molgen.mpg.de>
Subject: Re: [PATCH v2] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items
Date: Thu, 5 May 2022 09:53:19 -0400 (EDT)	[thread overview]
Message-ID: <229634522.46806.1651758799621.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <1540694996.45617.1651677847725.JavaMail.zimbra@efficios.com>



----- On May 4, 2022, at 11:24 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:

> ----- On May 4, 2022, at 10:43 AM, Robbie Harwood rharwood@redhat.com wrote:
> 
>> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> writes:
>> 
>>> +version_reverse_sort ()
>>> +{
>>> +  case $version_reverse_sort_sort_has_v in
>> 
>> Does this need to be its own variable, or could it just reuse
>> version_sort_sort_has_v?
> 
> We could do that, assuming that both sort -r -V and sort -V always work (or
> don't)
> in the same way.
> 
> Then I would change the test in version_reverse_sort to:
> 
> if sort -V </dev/null > /dev/null 2>&1; then
> 
> There is no point in calling this check with "-r" if it sets
> version_sort_sort_has_v.
> 
>> 
>>> +reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed 's/$/ 2/' | sed 's/\.old
>>> 2/ 1/' | version_reverse_sort | sed 's/ 1$/.old/' | sed 's/ 2$//')
>> 
>> Could the `sed | sed` pattern be collapsed into a single invocation
>> using multiple -e switches?1
> 
> I think we can straightforwardly turn "| sed 's/ 1$/.old/' | sed 's/ 2$//'"
> into "| sed -e 's/ 1$/.old/' -e 's/ 2$//'".
> 
> How to match that all lines ending with ".old" need to be replaced with a
> " 1" suffix, and all _other_ lines need to be suffixed with " 2" in a single
> sed invocation is unclear to me. Any idea ?

Actually with sed -e 's/$/ 2/' -e 's/\.old 2$/ 1/' the second -e applies on the
result of the first, so I can just do that.

Thanks,

Mathieu

> 
> Thanks,
> 
> Mathieu
> 
>> 
>> Be well,
>> --Robbie
> 
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


  reply	other threads:[~2022-05-05 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03 15:38 [PATCH v2] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items Mathieu Desnoyers
2022-05-04 14:43 ` Robbie Harwood
2022-05-04 15:24   ` Mathieu Desnoyers
2022-05-05 13:53     ` Mathieu Desnoyers [this message]
2022-05-05 14:22       ` Mathieu Desnoyers

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=229634522.46806.1651758799621.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    --cc=pmenzel@molgen.mpg.de \
    --cc=rharwood@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.