* Why sh-set-shell insert a space after #!
@ 2012-08-17 4:05 Leo
2012-08-17 5:22 ` Thierry Volpiatto
2012-08-17 7:18 ` Stephen J. Turnbull
0 siblings, 2 replies; 12+ messages in thread
From: Leo @ 2012-08-17 4:05 UTC (permalink / raw
To: emacs-devel
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 ;)
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 4:05 Why sh-set-shell insert a space after #! Leo
@ 2012-08-17 5:22 ` Thierry Volpiatto
2012-08-17 6:54 ` Leo
2012-08-24 17:08 ` Aurélien Aptel
2012-08-17 7:18 ` Stephen J. Turnbull
1 sibling, 2 replies; 12+ messages in thread
From: Thierry Volpiatto @ 2012-08-17 5:22 UTC (permalink / raw
To: emacs-devel
Leo <sdl.web@gmail.com> 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 ;)
Seems that this is wrong:
http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Magic_number
http://www.in-ulm.de/~mascheck/various/shebang/#details
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 5:22 ` Thierry Volpiatto
@ 2012-08-17 6:54 ` Leo
2012-08-17 7:06 ` Leo
2012-08-24 17:08 ` Aurélien Aptel
1 sibling, 1 reply; 12+ messages in thread
From: Leo @ 2012-08-17 6:54 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: emacs-devel
On 2012-08-17 13:22 +0800, Thierry Volpiatto wrote:
> Seems that this is wrong:
> http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Magic_number
> http://www.in-ulm.de/~mascheck/various/shebang/#details
Have I just discovered one of the oldest bugs? ;)
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 6:54 ` Leo
@ 2012-08-17 7:06 ` Leo
2012-08-22 17:17 ` Bastien
0 siblings, 1 reply; 12+ messages in thread
From: Leo @ 2012-08-17 7:06 UTC (permalink / raw
To: Chong Yidong; +Cc: Thierry Volpiatto, emacs-devel
On 2012-08-17 14:54 +0800, Leo wrote:
>> Seems that this is wrong:
>> http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Magic_number
>> http://www.in-ulm.de/~mascheck/various/shebang/#details
>
> Have I just discovered one of the oldest bugs? ;)
Hello Yidong,
Any objection to installing this tiny patch in emacs-24?
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el
index c44f1d73..201b4797 100644
--- a/lisp/progmodes/executable.el
+++ b/lisp/progmodes/executable.el
@@ -84,8 +84,9 @@ (defcustom executable-magicless-file-regexp "/[Mm]akefile$\\|/\\.\\(z?profile\\|
:group 'executable)
-(defcustom executable-prefix "#! "
+(defcustom executable-prefix "#!"
"*Interpreter magic number prefix inserted when there was no magic number."
+ :version "24.2"
:type 'string
:group 'executable)
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Why sh-set-shell insert a space after #!
2012-08-17 4:05 Why sh-set-shell insert a space after #! Leo
2012-08-17 5:22 ` Thierry Volpiatto
@ 2012-08-17 7:18 ` Stephen J. Turnbull
2012-08-17 8:05 ` Andreas Schwab
2012-08-17 15:50 ` Leo
1 sibling, 2 replies; 12+ messages in thread
From: Stephen J. Turnbull @ 2012-08-17 7:18 UTC (permalink / raw
To: Leo; +Cc: emacs-devel
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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 7:18 ` Stephen J. Turnbull
@ 2012-08-17 8:05 ` Andreas Schwab
2012-08-17 15:50 ` Leo
1 sibling, 0 replies; 12+ messages in thread
From: Andreas Schwab @ 2012-08-17 8:05 UTC (permalink / raw
To: Stephen J. Turnbull; +Cc: Leo, emacs-devel
"Stephen J. Turnbull" <stephen@xemacs.org> writes:
> IIRC, POSIX allows but doesn't require the space. However, some
> historical mostly-compatible shells had problems if there was no
> space.
There is some background information in
<http://www.in-ulm.de/~mascheck/various/shebang/#blankrequired>.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 7:18 ` Stephen J. Turnbull
2012-08-17 8:05 ` Andreas Schwab
@ 2012-08-17 15:50 ` Leo
2012-08-17 16:37 ` Thierry Volpiatto
1 sibling, 1 reply; 12+ messages in thread
From: Leo @ 2012-08-17 15:50 UTC (permalink / raw
To: Stephen J. Turnbull; +Cc: emacs-devel
On 2012-08-17 15:18 +0800, Stephen J. Turnbull wrote:
> 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.)
From my reading of the two links, separation #! and the path with a
space is abnormal and evidenced by all scripts I can find. So I think
the better default for executable-prefix is "#!", not "#! ".
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 15:50 ` Leo
@ 2012-08-17 16:37 ` Thierry Volpiatto
0 siblings, 0 replies; 12+ messages in thread
From: Thierry Volpiatto @ 2012-08-17 16:37 UTC (permalink / raw
To: emacs-devel
Leo <sdl.web@gmail.com> writes:
> On 2012-08-17 15:18 +0800, Stephen J. Turnbull wrote:
>> 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.)
>
> From my reading of the two links, separation #! and the path with a
> space is abnormal and evidenced by all scripts I can find. So I think
> the better default for executable-prefix is "#!", not "#! ".
Agree, also in all books, manuals I found , it is described like "#!/bin/bash"
and never "#! /bin/bash", same for python.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 7:06 ` Leo
@ 2012-08-22 17:17 ` Bastien
2012-08-23 0:53 ` Leo
0 siblings, 1 reply; 12+ messages in thread
From: Bastien @ 2012-08-22 17:17 UTC (permalink / raw
To: Leo; +Cc: Chong Yidong, emacs-devel, Thierry Volpiatto
Leo <sdl.web@gmail.com> writes:
> Any objection to installing this tiny patch in emacs-24?
I read the links and I also think the default should be "#!".
I just applied Leo's patch.
--
Bastien
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-22 17:17 ` Bastien
@ 2012-08-23 0:53 ` Leo
2012-08-23 9:54 ` Bastien
0 siblings, 1 reply; 12+ messages in thread
From: Leo @ 2012-08-23 0:53 UTC (permalink / raw
To: Bastien; +Cc: Chong Yidong, Thierry Volpiatto, emacs-devel
On 2012-08-23 01:17 +0800, Bastien wrote:
> I just applied Leo's patch.
Thanks. I wonder if a :version "24.3" is needed? ;)
Leo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-23 0:53 ` Leo
@ 2012-08-23 9:54 ` Bastien
0 siblings, 0 replies; 12+ messages in thread
From: Bastien @ 2012-08-23 9:54 UTC (permalink / raw
To: Leo; +Cc: Chong Yidong, emacs-devel, Thierry Volpiatto
Leo <sdl.web@gmail.com> writes:
> On 2012-08-23 01:17 +0800, Bastien wrote:
>> I just applied Leo's patch.
>
> Thanks. I wonder if a :version "24.3" is needed? ;)
Yep. Already done.
--
Bastien
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Why sh-set-shell insert a space after #!
2012-08-17 5:22 ` Thierry Volpiatto
2012-08-17 6:54 ` Leo
@ 2012-08-24 17:08 ` Aurélien Aptel
1 sibling, 0 replies; 12+ messages in thread
From: Aurélien Aptel @ 2012-08-24 17:08 UTC (permalink / raw
To: Thierry Volpiatto; +Cc: emacs-devel
On Fri, Aug 17, 2012 at 7:22 AM, Thierry Volpiatto
<thierry.volpiatto@gmail.com> wrote:
> Seems that this is wrong:
> http://en.wikipedia.org/wiki/Shebang_%28Unix%29#Magic_number
> http://www.in-ulm.de/~mascheck/various/shebang/#details
That was an interesting read, thank you.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-08-24 17:08 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17 4:05 Why sh-set-shell insert a space after #! Leo
2012-08-17 5:22 ` Thierry Volpiatto
2012-08-17 6:54 ` Leo
2012-08-17 7:06 ` Leo
2012-08-22 17:17 ` Bastien
2012-08-23 0:53 ` Leo
2012-08-23 9:54 ` Bastien
2012-08-24 17:08 ` Aurélien Aptel
2012-08-17 7:18 ` Stephen J. Turnbull
2012-08-17 8:05 ` Andreas Schwab
2012-08-17 15:50 ` Leo
2012-08-17 16:37 ` Thierry Volpiatto
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.