emacs-devel
[Top][All Lists]
Advanced

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

Why sh-set-shell insert a space after #!


From: Stephen J. Turnbull
Subject: Why sh-set-shell insert a space after #!
Date: Fri, 17 Aug 2012 16:18:07 +0900

Leo writes:
 > Hello all,
 > 
 > If you M-x sh-set-shell in a buffer it inserts something like:
 > 
 >   #! /bin/bash
 > 
 > I am curious why a space after #!. I read this page:
 > http://en.wikipedia.org/wiki/Shebang_(Unix). The newsgroup post by
 > Dennis Ritchie also has a space. But most scripts I have seen do not. So
 > I am curious ;)

IIRC, POSIX allows but doesn't require the space.  However, some
historical mostly-compatible shells had problems if there was no
space.  Since it never hurts with fully conforming shells, and
sometimes helps, it's a definite portability win.  (AFAIK there was no
particular correlation between this kind of non-conformance and other,
more important, non-conformance.)

Although it's not needed for bash, you can argue for it from
simplicity of sh-mode implementation (you don't need to detect the
shell and maintain a list of which shells care to decide whether to
insert the space) and consistency of style.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]