GNU bug report logs -
#13815
Wrong mode for files with awkward shebang lines
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13815 in the body.
You can then email your comments to 13815 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Tue, 26 Feb 2013 01:26:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Andrew Pennebaker <andrew.pennebaker <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 26 Feb 2013 01:26:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Some of my Scala code opens as Shell script major mode in Emacs, a problem
caused by several factors:
In order to enable dot-slashing for Scala scripts, programmers sometimes
start their code as follows:
#!/bin/sh
exec scala "$0" "$@"
!#
object Hello {
def main(args: Array[String]) {
println("Hello World!")
}
}
This is an awkward shebang line; due to the nature of shebangs, it must be
split across three lines of code, starting with #!/bin/sh.
This creates problems for Emacs, as Emacs uses `file` to detect which major
mode should be used, and `file` returns 'text/x-shellscript' when a file
begins #!/bin/sh, regardless of the file extension or programming language
content the file actually contains.
This could be solved a variety of ways, but I think the simplest is to
prioritize file extension over mimetype when a file extension is available.
We can't trust mimetypes for code that contains these awkward shebangs.
--
Cheers,
Andrew Pennebaker
www.yellosoft.us
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Tue, 26 Feb 2013 03:02:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 13815 <at> debbugs.gnu.org (full text, mbox):
> This could be solved a variety of ways, but I think the simplest is to
> prioritize file extension over mimetype when a file extension is available.
IIRC no strict priority will do, because for some files, the content is
more important than the filename.
> We can't trust mimetypes for code that contains these awkward shebangs.
[ FWIW Emacs doesn't actually use "mimtypes" but its own set of
file-contents-based rules. Not that it matters to this discussion,
really. ]
I think the right way is to check both file content and file name and if
the type they specify do not agree, fall back on a disambiguation
function, which should include various ad-hoc rules, and may ultimately
prompt the user if none of the ad-hoc rules resolved the ambiguity.
But in your specific case, you might get away with tweaking
inhibit-local-variables-regexps.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Tue, 26 Feb 2013 03:05:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 13815 <at> debbugs.gnu.org (full text, mbox):
Andrew Pennebaker wrote:
> #!/bin/sh
> exec scala "$0" "$@"
[...]
> This creates problems for Emacs, as Emacs uses `file` to detect which major
> mode should be used,
Emacs does not use `file', it uses interpreter-mode-alist (amongst other
things).
> This could be solved a variety of ways, but I think the simplest is to
> prioritize file extension over mimetype when a file extension is available.
It used to work that way prior to Emacs 22.1. Then it was changed for
reasons that were never properly explained IMO.
http://debbugs.gnu.org/3354
All you can do is add a mode: cookie.
Or use /usr/bin/env, IIUC
https://github.com/scala/scala/pull/9
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Tue, 26 Feb 2013 08:15:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 13815 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier wrote:
> IIRC no strict priority will do, because for some files, the content is
> more important than the filename.
I've never seen a real-world example where the #! line says one thing,
the filename extension says another, and the #! line is correct.
Does anyone have such an example?
(Going back to #3354, I now have 414 *.conf files in /etc, and not one
has a #! line.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Mon, 23 Aug 2021 01:15:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 13815 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> writes:
> It used to work that way prior to Emacs 22.1. Then it was changed for
> reasons that were never properly explained IMO.
>
> http://debbugs.gnu.org/3354
>
> All you can do is add a mode: cookie.
>
> Or use /usr/bin/env, IIUC
> https://github.com/scala/scala/pull/9
So I think the conclusion here is that this is working as designed, and
I'm closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) wontfix.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 23 Aug 2021 01:15:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
13815 <at> debbugs.gnu.org and Andrew Pennebaker <andrew.pennebaker <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Mon, 23 Aug 2021 01:15:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Mon, 23 Aug 2021 15:07:01 GMT)
Full text and
rfc822 format available.
Message #24 received at 13815 <at> debbugs.gnu.org (full text, mbox):
FTR, this issue would be fixed if auto-mode-alist took priority over
interpreter-mode-alist. That's how it was before Emacs 22.1.
I've never seen an explanation for why it was changed (ref bug#3354).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Mon, 23 Aug 2021 15:11:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 13815 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> writes:
> FTR, this issue would be fixed if auto-mode-alist took priority over
> interpreter-mode-alist. That's how it was before Emacs 22.1.
> I've never seen an explanation for why it was changed (ref bug#3354).
I thought it was because Debian changed the names of all their conf
files (many of which are shell scripts) to .conf?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Mon, 30 Aug 2021 15:12:02 GMT)
Full text and
rfc822 format available.
Message #30 received at 13815 <at> debbugs.gnu.org (full text, mbox):
Lars Ingebrigtsen wrote:
> I thought it was because Debian changed the names of all their conf
> files (many of which are shell scripts) to .conf?
I'll repeat my earlier comments in the hope that this time someone will
read them.
I have 468 .conf files in /etc on my Debian system.
A single one (it used to be zero years ago) has a #! line.
It is nftables.conf, which contains "#!/usr/sbin/nft -f".
Emacs has no mode for "nft".
Therefore this provides zero motivation for interpreter-mode-alist to
take precedence over auto-mode-alist.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13815
; Package
emacs
.
(Tue, 31 Aug 2021 01:55:02 GMT)
Full text and
rfc822 format available.
Message #33 received at 13815 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> writes:
> I'll repeat my earlier comments in the hope that this time someone will
> read them.
Sorry; I misremembered. Well -- then that's not a good reason to change
this (i.e., making #! take precedence over .suffix).
Does anybody remember what the rationale was for this change? It's
somewhat puzzling behaviour.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 28 Sep 2021 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 210 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.