From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gcWZu-0001h1-Rn for mharc-grub-devel@gnu.org; Thu, 27 Dec 2018 09:24:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gcWZo-0001dg-Mo for grub-devel@gnu.org; Thu, 27 Dec 2018 09:23:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gcWZj-000240-GB for grub-devel@gnu.org; Thu, 27 Dec 2018 09:23:56 -0500 Received: from mta.tntech.edu ([149.149.2.87]:48043) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gcWZj-0000cr-9c for grub-devel@gnu.org; Thu, 27 Dec 2018 09:23:51 -0500 Received: from norden.math.tntech.edu (unknown [149.149.136.15]) by mta.tntech.edu (Postfix) with ESMTP id D12D8300004F for ; Thu, 27 Dec 2018 08:23:12 -0600 (CST) Received: by norden.math.tntech.edu (Postfix, from userid 742) id C4CB52572B73; Thu, 27 Dec 2018 08:23:12 -0600 (CST) From: Jeff Norden To: grub-devel@gnu.org Subject: Re: Proposed PATCH to allow control of the kernel ordering in grub.cfg In-Reply-To: (message from Jeff Norden on Thu, 20 Dec 2018 18:26:20 -0600) Date: Thu, 27 Dec 2018 08:23:12 -0600 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 149.149.2.87 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Dec 2018 14:23:57 -0000 Well, DRAT! Nothing is ever as simple as it seems, is it? 1) Deleting the tr after the grep actually seems to break the patch. My apologies for not testing this more carefully in advance. It looks like the second tr masks grep's exit status, which is important b/c the script runs with 'set -e' and exits immediately on any "error". Seems like changing |tr to ||true will work. 2) After reading Mihai Moldovan's comments above, I think it is better to just use grep rather than egrep. You could always add "-E" at the beginning of the GRUB_PREFERRED_KERNEL string if you need to. With GNU grep, egrep and grep have the same functionality, and only differ in when you need to backslash-escape some of the special characters. 3) Thinking about the second point, people might want to include other grep flags in GRUB_PREFERRED_KERNEL, such as "-F", "-i", "-x", or even "-P" (my personal favorite :-). BUT, it then becomes clear that you can't count 100% on grep to either return an empty string or entries from $list. If you accidentally include "-l" or "-c", then $linux might be set to "(standard input)" or "1". Potentially, this could put 10_linux into an infinite loop, but it would probably just crash quickly due to "set -e" again. In any case, this could leave someone's system in an un-bootable state. So, I think it will be necessary to check the result of `grep "${GRUB_PREFERRED_KERNEL}"` more carefully. Hopefully, I'll have some time to work on this next week. I'll submit a revised patch when I get it fixed. I'm afraid it won't be quite as simple as I originally thought, but it shouldn't be too much longer. Happy New Year's to all! -Jeff