]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
scripts/makefile-getvar: be more resilient
authorRoss Burton <ross.burton@arm.com>
Thu, 18 Dec 2025 17:42:43 +0000 (17:42 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 22 Dec 2025 17:54:58 +0000 (17:54 +0000)
Check that we've been passed enough arguments (at least the Makefile and
one variable), and that the Makefile specified is actually a file.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/makefile-getvar

index 4a07055e687aceec9256dfde184566493165fda1..e8a983276676b8d8541e99a84ca92be27d4a1719 100755 (executable)
 
 set -eu
 
+if [ $# -lt 2 ]; then
+       echo "Get a variable's value from a Makefile:"
+       echo "$ makefile-getvar Makefile VARIABLE VARIABLE ..."
+       exit 0
+fi
+
 MAKEFILE=$1
 shift
 
+if [ ! -f $MAKEFILE ]; then
+       echo $MAKEFILE is not a file
+       exit 1
+fi
+
 for VARIABLE in $*; do
        make -f - $VARIABLE.var <<EOF
 include $MAKEFILE