Better error checking of config file by build scripts
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.
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).
sed -i 's|./_install|$(PREFIX)|g' .config
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.
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:
> +set -e
> . ./.config || exit 1
> +set +e
IMHO the posix way is
command . ./.config || exit 1
The set -e/+e seems fragile, see:
Can you please check if this works for you?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the busybox