#! is definitly received by the kernel where it undergoes transformation into a normal exec() the reasoning can be found in transcript from irc.freenode.org/#perl code mentioning ->sh_bang found in linux/fs/binfmt_script.c
ignore this whole post, as it is wrong, and I was wrong
"This is not Perl code. It is not really shell code either. This first line is a means by which, only under Unix systems, a Unix OS kernel can determine which interpreter to run this script under. If the shell becomes involved in this process at all, and I suppose under some very ancient Unix made by some vendor in the benighted depths of history, that could happen, then one might see the shell execute which perl and report back to the kernel what path to use for invoking the Perl interpreter."
Actually, it is shell code, taken from `man sh` the default shell on many older systems, to which all shells base the implimentation of #! on
"If the program is a file beginning with #!, the remainder of the first line specifies an interpreter for the pro-
gram. The shell executes the specified interpreter on operating systems that do not handle this executable format
themselves. The arguments to the interpreter consist of a single optional argument following the interpreter name
on the first line of the program, followed by the name of the program, followed by the command arguments, if any."
Intrepid is sticking to his words. I believe he is wrong, and this is shell specific, and that it tells the shell what interpreter to invoke, his conversation is as follows.
Intrepid: EvanCarrolll, you're wrong about Re: Shebang Line (was: different first line in perl).
Intrepid: tetchy?
Intrepid: I'd rather encounter a serene Yellow Giant than a tetchy red dwarf.
EvanCarroll: Intrepid according to who, I believe it is you that is wrong
EvanCarroll: Intrepid "the kernel" does not parse text, including shebang lines
Intrepid: Ah there you are, EvanCarrol. Just /msg'd you.
Intrepid: Ooops, apparently spelled you monknick wrong, oh well ;-)
EvanCarroll: can we get some more attention at 575497 I would be curios to get this resolved, as I have a downvote from it and i know who it comes from, ;) intrepid.
EvanCarroll: Intrepid I still think it is you that is wrong, I even quoted sh's man page
Intrepid: You unfortuantely misinterpreted sh' manpage,
Intrepid: ... and my writeup had already addressed this issue btw.
EvanCarroll: Intrepid I'm not removing my writeup, I'm still convinced you are wrong, Do your homework or cite your source.
Intrepid: If you are thinking of taking the d/v personally, EvanCarroll, don't. You picked a bad day to reply to that node; and anyway I famously don't put any credence in XP whatsoever.
Intrepid: I'll let time take of it, Evancarroll. As I said, this is old old news, and I'm multitasking a gazillion diff projects. Keep asking around for people to tell you what's correct, if you like.
Can someone else please take a side/show support etc, or cite a source. Thanks.
From freenode.org##linux
04:29 < EvanCarroll> #! is handeled by the shell right, and has absolutely nothing to do with the kernel
04:29 < EvanCarroll> shebang lines
04:29 < Triffid_Hunter> EvanCarroll: if started by a shell, yes
04:29 < koala_man> it's for the kernel
freenode.org##perl
04:20 < EvanCarroll> What is responsible for the shebang interpretation
04:20 < EvanCarroll> the kernel or the shell?
04:20 < EvanCarroll> I thought the shell
04:20 < Dragon22> shell
04:42 < infi> EvanCarroll: I actually think you're wrong on the matter. There is synergy with the '#' being a somewhat
normal script comment character, thus a shell ignores the line if you use 'sh foo.sh', but I believe that the
'#!' is just a human-readable form of an executable magic number interpreted by execve(2), just like any other
('MZ' for DOS, \177ELF for ELF, etc)
04:44 < EvanCarroll> hrm I could be wrong, I just could have sworn that I read this in begining perl way back when i was
first learning, and it is in both sh and bash man page with no mention of the kernel
04:45 < hawkaloogie> EvanCarroll, Unix kernel, not Linux kernel
04:45 < infi> 'magic' is inconclusive about it, as it interprets it as a string, but man 2 execve seems to confirm that. It
also seems likely because of the way the 'Kernel support for MISC binaries' feature of the kernel works, via
magic number detection associated with an external program. but I haven't found anything conclusive
04:46 < hawkaloogie> last i read it was old, kind of a legacy
04:46 < infi> EvanCarroll: ah, here we go: http://en.wikipedia.org/wiki/Shebang_(Unix)
04:48 < bl0ndie> EvanCarroll prefers the hebang.
04:48 < EvanCarroll> infi: I've had that referenced now like twice where does it mention the kernel
04:48 < EvanCarroll> bl0ndie: cute. bend over.
04:48 < bl0ndie> o.o
04:48 < hawkaloogie> EvanCarroll, read this: http://homepages.cwi.nl/~aeb/std/hashexclam-1.html
04:49 < hawkaloogie> #! was chosen because it wasn't being used as a binary format header yet
04:49 < infi> this seems to agree, too: http://www.in-ulm.de/~mascheck/various/shebang/
04:50 < infi> EvanCarroll: yeah, I'm hesitant to use wikipedia as an authoritative source, too
04:50 < EvanCarroll> so most definitly it is the kernel
04:50 < EvanCarroll> wow how obscure, I would have never though that in a million years
.
irc.freenode.org/#gentoo
04:36 < EvanCarroll> What handels the shebang line the kernel or the shell?
04:36 < transient> EvanCarroll: kernel i believe
04:39 < EvanCarroll> Does anyone know for certain if the kernel or shell is responsible for shebang i thought shel.l
04:40 < Slowking_Man> kernel
.
irc.freenode.org/#bash
04:37 < EvanCarroll> What handels the shebang line the kernel or the shell?
04:37 < twkm> kernel.
..
Evan Carroll www.EvanCarroll.com
| [reply] |