commit efa7acfe58b463d48d6e7dfbec38e69a2f921243
parent 00a158fd1958df4d55385a3ada8aaa0c5d3f970c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 10 Jan 2025 20:01:17 +0100
make: Check for UNDEF in macroinfo()
Long time ago lookup() returned a macro with a NULL string,
but this is not true anymore and it returns an empty string
but with where marked as UNDEF.
Diffstat:
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/cmd/scc-make/parser.c b/src/cmd/scc-make/parser.c
@@ -102,7 +102,7 @@ macroinfo(char *name, int *pwhere, Macro **mpp)
s = mp->value;
where = mp->where;
- if (!s && !hide) {
+ if (where == UNDEF && !hide) {
where = ENVIRON;
s = getenv(name);
}
diff --git a/tests/make/execute/0103-env.sh b/tests/make/execute/0103-env.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export EFLAGS=World
+
+trap 'rm -f $tmp1 $tmp2' EXIT INT TERM HUP
+
+tmp1=tmp1.$$
+tmp2=tmp2.$$
+
+cat > $tmp1 <<EOF
+Hello World
+EOF
+
+scc-make -f - <<'EOF' > $tmp2 2>&1
+FLAGS=Hello $(EFLAGS)
+all:
+ @echo $(FLAGS)
+EOF
+
+diff $tmp1 $tmp2