Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: (OT) Fixing Line Endings - patch the shell (kernel)

by tye (Sage)
on Nov 30, 2006 at 17:18 UTC ( #587016=note: print w/ replies, xml ) Need Help??

in reply to Re^2: (OT) Fixing Line Endings - patch the shell
in thread (OT) Fixing Line Endings

Yes, there's no good excuse for the kernel failing to ignore what is clearly whitespace. Someone please fix Linux already. This bug has existed for way too long.

( And how come it seems that there aren't any Linux users that know that she-bang lines are handled by the kernel? I think that change even predates Linux so there never was a Linux where the shell had to do the #!-handling. How many decades does it take for people to catch on? :)

- tye        

Comment on Re^3: (OT) Fixing Line Endings - patch the shell (kernel)
Replies are listed 'Best First'.
Re^4: (OT) Fixing Line Endings - patch the shell (kernel)
by jbert (Priest) on Nov 30, 2006 at 17:26 UTC
    Interestingly, the kernel code in question (C, not perl I'm afraid :-) already does this:
    while (cp > bprm->buf) { cp--; if ((*cp == ' ') || (*cp == '\t')) *cp = '\0'; else break; }
    i.e. it finished the executable name at the first space or tab. I guess a better patch would be to change that if test to also null out '\r' (hmm...and probably form-feed and others whilst we're at it).

    I wonder how loudly people would scream if this were proposed as a kosher kernel patch. It breaks backwards compatability quite badly, but perhaps only for people who deserve it...

      Just change that to:

      if (isspace(*cp)) *cp = '\0';
      Don't forget to #include <linux/ctype.h> up top, though, to get this macro...

Re^4: (OT) Fixing Line Endings - patch the shell (kernel)
by imp (Priest) on Nov 30, 2006 at 17:30 UTC
    When I first started with openbsd and freebsd 6 years ago I assumed the shell was responsible for the shebang, and never revisited the topic to challenge that assumption. It was never quite important enough for me to research it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://587016]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2015-10-07 10:59 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (179 votes), past polls