From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nmcNZ-00047w-Ml for mharc-grub-devel@gnu.org; Thu, 05 May 2022 10:22:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmcNX-00043H-AD for grub-devel@gnu.org; Thu, 05 May 2022 10:22:51 -0400 Received: from mail.efficios.com ([167.114.26.124]:37018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmcNV-0005QC-3f for grub-devel@gnu.org; Thu, 05 May 2022 10:22:50 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id E836F3C18A6; Thu, 5 May 2022 10:22:47 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id YNn9G7Pt2LaJ; Thu, 5 May 2022 10:22:47 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 7FB293C171E; Thu, 5 May 2022 10:22:47 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 7FB293C171E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1651760567; bh=fB5mutwUnFx5YTda2Uim7K3k7kDWivPzzQ7NKgbk7EI=; h=Date:From:To:Message-ID:MIME-Version; b=WPGRjKKsmo/Jfap8yodX3Ah5+bSCsWtDZ+CStdNKm69G35jn3W31E+BmUzcVkpuBB psnBEAZZRhHb0EkSk9+qkrCZbakjseql32T/5a5/KApplmLNCngH5ISjA8fVHJA40E Om3dZtq6KjcHkWyHnhadHTg2FXlQSk3nfpxBmDeOhF4yHXQ3SkGmVa3qF46Mjz4yrN RMbkVktshwXGHuV9lPII+mZByJwe961m2uIp5e4E/GkLPtoTRO7zaJFQTcRnJCeCKp hUQNTlUfJ51Vy8Ydbec1GFKh8CDrLn9QksX7ClAkK6uCKr9x/YAV91GmQvEPjxzZx5 BlEFPTXfP0V+A== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mJ2li234M-ET; Thu, 5 May 2022 10:22:47 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 7269A3C171B; Thu, 5 May 2022 10:22:47 -0400 (EDT) Date: Thu, 5 May 2022 10:22:47 -0400 (EDT) From: Mathieu Desnoyers To: Robbie Harwood Cc: Daniel Kiper , Vladimir phcoder Serbinenko , grub-devel , Paul Menzel Message-ID: <1282074472.46877.1651760567343.JavaMail.zimbra@efficios.com> In-Reply-To: <229634522.46806.1651758799621.JavaMail.zimbra@efficios.com> References: <20220503153812.991408-1-mathieu.desnoyers@efficios.com> <1540694996.45617.1651677847725.JavaMail.zimbra@efficios.com> <229634522.46806.1651758799621.JavaMail.zimbra@efficios.com> Subject: Re: [PATCH v2] grub-mkconfig linux: Fix quadratic algorithm for sorting menu items MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4257 (ZimbraWebClient - FF100 (Linux)/8.8.15_GA_4257) Thread-Topic: grub-mkconfig linux: Fix quadratic algorithm for sorting menu items Thread-Index: Z7884qEjOjUcI+SWNptOHhBHpOmCuw/o7M77JQt0ft4= Received-SPF: pass client-ip=167.114.26.124; envelope-from=compudj@efficios.com; helo=mail.efficios.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 14:22:51 -0000 ----- On May 5, 2022, at 9:53 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: > ----- 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 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 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. And even easier to comprehend with a negated regex as address for the second expression: sed -e 's/\.old$/ 1/' -e '/ 1$/! s/$/ 2/' Thanks, Mathieu > > Thanks, > > Mathieu > >> >> Thanks, >> >> Mathieu >> >>> >>> Be well, >>> --Robbie >> >> -- >> Mathieu Desnoyers >> EfficiOS Inc. >> http://www.efficios.com > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com