Re: Bug in #! processing

From: Scot Hetzel <swhetzel_at_gmail.com>
Date: Thu, 30 Sep 2004 09:45:27 -0500
On Thu, 30 Sep 2004 13:21:54 +0100, Ceri Davies <ceri_at_submonkey.net> wrote:
> I agree(ish); I don't think that the kernel should do anything special
> here either and I think that the "correct" thing to do would be to back
> out that revision.  Unfortunately the FreeBSD userbase can write a lot
> of scripts in 4 and a half years and we probably can't get away with it.
> Perhaps it could be done in -CURRENT, but I'd really like to see some
> other opinions.  For clarity, what I'm proposing is the application of
> the attached diff.  Opinions from anyone?
> 
Instead of backing out that revision, change the test for # to include
a check for white space before it, this way those who have used the #
character as a comment on the first line won't have to change any
thing.

-	for (ihp = &image_header[2]; *ihp != '\n' && *ihp != '#'; ++ihp) {
+	for (ihp = &image_header[2]; *ihp != '\n' && ! (*ihp-1 == '[white
space]' && *ihp == '#'); ++ihp) {

where [white space] could be either a tab or a space character.

or just check if a dash is before #.

+	for (ihp = &image_header[2]; *ihp != '\n' && ! (*ihp-1 == '-' &&
*ihp == '#'); ++ihp) {


Scot

Discaimer: the code may not work as written adjust to your liking.
Received on Thu Sep 30 2004 - 12:45:48 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:14 UTC