Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site ncrcae.UUCP
Path: utzoo!watmath!clyde!cbosgd!cbdkc1!desoto!packard!edsel!bentley!hoxna!houxm!whuxlm!harpo!decvax!mcnc!ncsu!ncrcae!wescott
From: wescott@ncrcae.UUCP (Mike Wescott)
Newsgroups: net.bugs.usg,net.unix-wizards
Subject: Re: Make bug
Message-ID: <2105@ncrcae.UUCP>
Date: Wed, 6-Feb-85 15:02:31 EST
Article-I.D.: ncrcae.2105
Posted: Wed Feb  6 15:02:31 1985
Date-Received: Sat, 9-Feb-85 07:36:27 EST
References: <305@ist.UUCP>
Reply-To: wescott@ncrcae.UUCP (Mike Wescott)
Organization: NCR, Columbia, SC
Lines: 39
Xref: watmath net.bugs.usg:170 net.unix-wizards:11930
Summary: 

David Tilbrook, Imperial Software Technology, London England in <305@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