Better error checking of config file by build scripts

Paul Larkin sinbad_4273 at yahoo.com
Mon Dec 21 21:25:01 UTC 2020


 As you suggested, I just tested using the command builtin command and unfortunately it doesn't seem to change anything from the original scripts' behavior whereas the errexit flag does cause the script and the calling make to abort on error. I don't know anything about the POSIX rules regarding /bin/sh but a google search found this document that mentions errexit throughout as a normal feature.

https://arxiv.org/pdf/1907.05308.pdf
After cloning busybox, I use the small script below to generate an error in the .config and see if the build aborts on error or continues blindly all the way through. I am using ubuntu 18.04 LTS which uses dash for non-interactive shells (but I also tested using bash).

#!/bin/sh
make defconfig
sed -i 's|./_install|$(PREFIX)|g' .config
make clean
make CONFIG_PREFIX="./_install"
Note that we are only setting the errexit flag briefly while sourcing a .config file which is also included by make. This means mostly simple variable assignments and comments should be in there not complex fringe shell construct cases.
Can others detect this error and abort the make without using the errexit flag? I'm ok with whatever works and is most portable.

Thanks.
    On Monday, December 21, 2020, 2:23:02 a.m. EST, Bastian Bittorf <bb at npl.de> wrote:  
 
 On Mon, Dec 21, 2020 at 05:28:36AM +0000, Paul Larkin wrote:
>  #!/bin/sh
>  
> +set -e
>  . ./.config || exit 1
> +set +e

IMHO the posix way is

command . ./.config || exit 1

The set -e/+e seems fragile, see:
https://www.in-ulm.de/~mascheck/various/set-e/

Paul:
Can you please check if this works for you?

bye, Bastian
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20201221/3e827f97/attachment.html>


More information about the busybox mailing list