[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Major mode of orgweb/publish.sh?
From: |
Max Nikulin |
Subject: |
Re: Major mode of orgweb/publish.sh? |
Date: |
Wed, 19 Apr 2023 23:54:42 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 |
On 14/04/2023 16:20, Ruijie Yu wrote:
Ihor Radchenko writes:
Ruijie Yu writes:
Major mode was erronously set to shell-script-mode because of the empty line.
Empty line was added by mistake, see "23.3 Choosing File Modes" in the
Emacs manual:
(info "(emacs) Choosing Modes")
https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html
----
When the first line starts with ‘#!’, you usually cannot use the ‘-*-’
feature on the first line, because the system would get confused when
running the interpreter. So Emacs looks for ‘-*-’ on the second line in
such files as well as on the first line. The same is true for man pages
which start with the magic string ‘'\"’ to specify a list of troff
preprocessors.
----
The line in question is inline stdin redirect
in shell. "#..." is what is fed to exec emacs.
There is no stdin redirection,
":"; exec emacs --script "$0" #...
line instructs shell to stop interpreting this file and to execute emacs
instead, passing file name for this script. This line is valid for both
shell (sequence of "true" and "exec" commands) and elisp (string and
comment). So this is a valid elisp file for emacs.
I was about to propose changing the shbang line into just
#!/usr/bin/emacs -x
It would fix path to emacs binary. Currently double trampoline is used.
I see no point in /usr/bin/env since location of shell is considered
fixed. That is why
#!/bin/sh
should work as well. Shell looks up for emacs in the $PATH environment
variable. /usr/bin/env can do it as well, but shebang allows just single
argument. Latest GNU env versions are able to split passed string to
separate argument (-S option), but currently interpreting of script
arguments as emacs options are suppressed by -- before "$@", so they are
passed as `argv' list elements.
#!/usr/bin/env -S emacs --quick --script
should work, but it is less portable since relies on recent GNU env
version and less safe since script options may modify emacs behavior.
Re: Major mode of orgweb/publish.sh?, Ihor Radchenko, 2023/04/14