On Tue, Jan 16, 2024 at 11:34 AM Michael Chang via Grub-devel <grub-devel@gnu.org> wrote: > > On Fri, Jan 12, 2024 at 05:58:02PM +0100, Itxaka serrano wrote: > > Hey all, > > > > I opened a bug because this behaviour doesnt seem correct to me: > > > > https://savannah.gnu.org/bugs/?65154 > > > > > > Example: > > > > grub> hello > > error: ../../grub-core/script/function.c:119:can't find command `hello'. > > grub> echo $? > > 0 > > > > > > Kind of weird because on the code it seems like its returning a > > GRUB_ERR_UNKNOWN_COMMAND which should not be zero. I had a quick look and > > maybe its becuase on line 1018 of grub-core/script/execute.c we print the > > error but always return 0 > > https://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/script/execute.c#n1018 > > > > Is this expected behaviour or is it a mistake and we should not only print > > the error but return the actual error? > > The behavior is expected: > > https://git.savannah.gnu.org/cgit/grub.git/commit/?id=bc028f2f86. > $? is set before clearing error so it should be set to unknown command. So looks like there is more to it.
> Given the limited context, it remains unclear if the rationale behind > this change can be easily retraced today. > > My take is that this modification may have been implemented to support > the continued functionality of older `grub.cfg` files, even after > certain commands have been removed. This ensures compatibility with the > latest version of GRUB. Alternatively, it seems reasonable to halt > execution when encountering a missing command, considering the potential > consequence of such situations. We can have an equivalent of "shopt -e" for those cases. Current default matches default sh use. _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel