[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Mass bugfiling potential: 'rules' with space



On Fri, Oct 11, 2002 at 01:56:30PM +0100, Matthew Garrett wrote:
> No, NetBSD passes a single argument. It's just that it passes "-f "
> rather than "-f", and make treats these differently. Your "bar baz"
> example will behave in the same way on NetBSD. Now, can anyone find a
> reference that suggests that NetBSD is wrong to do this? If not, I'm not
> happy about trying to get NetBSD upstream to accept the change.
> 
> Just to make it absolutely clear - "#!/usr/bin/make -f " on NetBSD
> results in "make" "-f ", *not* "make" "-f" "". I'm inclined to think
> that the rules files in question are buggy, and it's just luck that they
> happen to run on Linux. Oddly, this does seem to be a deliberate
> decision - from fs/binfmt_script.c in the Linux source, we have:
> 
>                 if ((*cp == ' ') || (*cp == '\t'))
>                         *cp = '\0';
> 
> Ted, was there any particular reason for this?

Actually, the above quoted code isn't what strips the trailing
whitespace.  That's done earlier in the function, here:

	while (cp > bprm->buf) {
		cp--;
		if ((*cp == ' ') || (*cp == '\t'))
			*cp = '\0';
		else
			break;
	}

But in any case, the reason why it's done is because it makes the
system more robust when hidden white space doesn't cause scripts to
hysteriously fail.  The fact that hidden whitespace can drastically
change how a script works (or doesn't work) is IMHO a really bad idea.

That being said, all of the relevant standards are silent about what
happens regarding whitespace, or if there is any kind of whitespace in
the optional argument at all.  So what NetBSD and Linux are both doing
is correct, and if the scripts are to be maximally portable, the
excess spaces should be removed.

						- Ted



Reply to: