Make bug

Mike Wescott wescott at ncrcae.UUCP
Thu Feb 7 06:02:31 AEST 1985


David Tilbrook, Imperial Software Technology, London England in <305 at ist.UUCP>
points up a bug in make whereby the shell's filename  expansion is suppressed
when make is invoked:

	make -f - < descfile

rather than:

	make -f descfile

The bug is actually in /bin/sh.  In sh/expand.c around line 112 the shell
attemps to open a directory to scan for file name expansions:

	if ((dirf = open(*s ? s : ".", 0)) > 0)
	{
		if (fstat(dirf, &statb) != -1 &&
		    (statb.st_mode & S_IFMT) == S_IFDIR)
			dir++;
		else
			close(dirf);
	} 

The asuumption is that open will never return 0; the check should be >= 0.

How is it that stdin is not open?  In make, in main.c while parsing the
-f flag, the routine rddescf() is called.  rddescf() fopen's the file named
by the argument following the -f flag unless it is "-".  The file pointer
retruned by fopen or stdin is then passed to rdd1() which reads and fcloses
the file passed to it; hence when "-f -" is used stdin is closed before
/bin/sh is called.  This is also a bug since

	make -f - -f -

won't work properly, but then it's kinda silly anyway.

Mike Wescott
NCR Corp.
mcnc!ncsu!ncrcae!wescott
akgua!usceast!ncrcae!wescott



More information about the Comp.unix.wizards mailing list