Index | Thread | Search

From:
Marc Espie <marc.espie.openbsd@gmail.com>
Subject:
Re: make: refuse empty variable names
To:
tech@openbsd.org
Date:
Tue, 16 Jun 2026 12:11:41 +0200

Download raw body.

Thread
On Sun, Jun 14, 2026 at 11:01:47AM +0200, Marc Espie wrote:
> Found by accident while looking at www/dufs/crates.inc
> 
> gmake refuses empty variable names, I think we should too.
> 
> Especially if we make typos and end up expanding empty stuff.
> 
> (currently, stuff that starts with an = will be treated as a comment)
> 
> This needs to get through a full release, obviously...

Of course first version was wrong. Namely the check needs to happen
*after* the parser has determined we are in a variable assignment.

Index: parsevar.c
===================================================================
RCS file: /home/espie/cvs/src/usr.bin/make/parsevar.c,v
diff -u -p -r1.18 parsevar.c
--- parsevar.c	18 Jun 2024 02:11:03 -0000	1.18
+++ parsevar.c	16 Jun 2026 08:00:51 -0000
@@ -133,6 +133,8 @@ parse_variable_assignment(const char *li
 		}
 	}
 
+	if (name.s == name.e)
+		Parse_Error(PARSE_FATAL, "empty variable name");
 	arg++;
 	while (ISSPACE(*arg))
 		arg++;