Better error checking of config file by build scripts

Paul Larkin sinbad_4273 at
Mon Dec 21 05:28:36 UTC 2020

In the dd-wrt community build project we noticed some errors buried for years in the huge build log and traced them back to a malformed line in a busybox .config file (our fault). The existing busybox scripts' error checking will only get triggered if the malformed line is the last one executed in the .config being sourced.

The bad line (see below) passed the gnu make syntax checking but unknowingly failed /bin/sh syntax checking. 


Here's a possible way to trigger errors no matter on which line the error occurs. Note that the trylink script sources the .config file twice but the below patch only sets the "exit immediately" option during one of those times. In our case, one fatal error is enough to notice the bad .config file. Just noticed trylink does not have "|| exit 1" after sourcing so perhaps a missing/invalid .config is acceptable in that case and shouldn't be patched? I know nothing about busybox build scripts...

Have been a fan of busybox for years. Congrats on a cool product!

diff --git a/scripts/embedded_scripts b/scripts/embedded_scripts
index aa7bf3e8a..bb060e787 100755
--- a/scripts/embedded_scripts
+++ b/scripts/embedded_scripts
@@ -1,6 +1,8 @@
+set -e
 . ./.config || exit 1
+set +e
diff --git a/scripts/ b/scripts/
index 718788e0b..dedf8e74e 100755
--- a/scripts/
+++ b/scripts/
@@ -3,7 +3,9 @@
 # scripts/ include/common_bufsiz.h
+set -e
 . ./.config || exit 1
+set +e
diff --git a/scripts/trylink b/scripts/trylink
index 6b74f092d..bf3f44d33 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -228,7 +228,9 @@ else
+set -e
 . ./.config
+set +e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the busybox mailing list