----- On May 5, 2022, at 9:53 AM, Mathieu Desnoyers mathieu.desnoy...@efficios.com wrote:
> ----- On May 4, 2022, at 11:24 AM, Mathieu Desnoyers > mathieu.desnoy...@efficios.com wrote: > >> ----- On May 4, 2022, at 10:43 AM, Robbie Harwood rharw...@redhat.com wrote: >> >>> Mathieu Desnoyers <mathieu.desnoy...@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. 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 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel