unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs
@ 2023-11-02 20:57 Kévin Le Gouguec
  2023-11-12 17:53 ` Kévin Le Gouguec
  0 siblings, 1 reply; 7+ messages in thread
From: Kévin Le Gouguec @ 2023-11-02 20:57 UTC (permalink / raw)
  To: 66902

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Hello,

While Emacs correctly picks makefile-gmake-mode when visiting a file
with the following shebang:

  #!/usr/bin/make -f

It fails to do so for this shebang:

  #!/usr/bin/env -S make -f

env(1) suggests -S is the idiomatic way to pass arguments to programs in
shebangs:

>    -S/--split-string usage in scripts
>        The -S option allows specifying multiple parameters in a script.
>        Running a script named 1.pl containing the following first line:
> 
>               #!/usr/bin/env -S perl -w -T
>               ...
> 
>        Will execute perl -w -T 1.pl .
> 
>        Without the '-S' parameter the script will likely fail with:
> 
>               /usr/bin/env: 'perl -w -T': No such file or directory

I've poked at lisp/files.el; the attached diff seems sufficient to make
Emacs pick makefile-gmake-mode .


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: files.diff --]
[-- Type: text/x-diff, Size: 568 bytes --]

diff --git a/lisp/files.el b/lisp/files.el
index 3d838cd3b8c..97594ff8a13 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3246,7 +3246,8 @@ inhibit-local-variables-p
 
 (defvar auto-mode-interpreter-regexp
   (purecopy "#![ \t]?\\([^ \t\n]*\
-/bin/env[ \t]\\)?\\([^ \t\n]+\\)")
+/bin/env[ \t]\\(?:\\(?:-S\\|--split-string\\)[ \t]\\)?\\)?\
+\\([^ \t\n]+\\)")
   "Regexp matching interpreters, for file mode determination.
 This regular expression is matched against the first line of a file
 to determine the file's mode in `set-auto-mode'.  If it matches, the file

[-- Attachment #3: Type: text/plain, Size: 1550 bytes --]


Questions before proceeding to ChangeLog entries & regression tests:

1. Is this something we would like Emacs to recognize out of the box, or
is it too niche?

2. What about the more general forms shown in (info "(coreutils) env
invocation")?

  #!/usr/bin/env -[v]S[OPTION]... [NAME=VALUE]... COMMAND [ARGS]...

3. Assuming we do want to amend that regexp, would it be possible to use
rx here?  OT1H guessing "no" because files.el is pre-reloaded, whereas
rx.el is not; OTOH I see that files.el requires easy-mmode at
compile-time, and that package does not show up in loadup.el, so…
settling for "maybe?"

WDYT?


In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.37, cairo version 1.16.0) of 2023-08-20 built on hirondell
Repository revision: 652e45b70d82e6f615febe00553dbded80557845
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure
 --cache-file=/home/peniblec/.cache/emacs/config,src,emacs,master
 --with-cairo --with-gconf --with-sqlite3 --with-xinput2'

Configured features:
ACL CAIRO DBUS FREETYPE GCONF GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-11-19 10:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 20:57 bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Kévin Le Gouguec
2023-11-12 17:53 ` Kévin Le Gouguec
2023-11-18  9:41   ` Eli Zaretskii
2023-11-18 10:31     ` Kévin Le Gouguec
2023-11-18 17:44       ` Kévin Le Gouguec
2023-11-19  9:09         ` Eli Zaretskii
2023-11-19 10:51           ` Kévin Le Gouguec

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).