I’ve seen both:
#!/path/...
#! /path/...
What’s right? Does it matter? Is there a history?
I’ve heard that an ancient version of Unix required there not be a space. But then I heard that was just a rumor. Does anyone know for certain?
Edit: I couldn’t think where better to ask this. It is programming related, since the space could make the program operate in a different way, for all I know. Thus I asked it here.
I also have a vague memory that whitespace was not allowed in some old Unix-like systems, but a bit of research doesn’t support that.
According to this Wikipedia article, the
#!syntax was introduced in Version 8 Unix in January, 1980. Dennis Ritchie’s initial announcement of this feature says:[SNIP]
It’s conceivable that some later Unix-like system supported the
#!syntax but didn’t allow blanks after the!, but given that the very first implementation explicitly allowed blanks, that seems unlikely.leonbloy’s answer provides some more context.
UPDATE :
The Perl interpreter itself recognizes a line starting with
#!, even on systems where that’s not recognized by the kernel. Runperldoc perlrunor see this web page for details.Perl also permits whitespace after the
#!.(Personally, I prefer to write the
#!line without whitespace, but it will work either way.)And leonjoy’s answer points to this web page by Sven Mascheck, which discusses the history of #! in depth. (I mention this now because of a recent discussion on comp.unix.shell.)