From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Date: Thu, 02 Nov 2023 21:57:25 +0100 Message-ID: <87ttq3lvpm.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26896"; mail-complaints-to="usenet@ciao.gmane.io" To: 66902@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 02 21:58:37 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qyelx-0006nj-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Nov 2023 21:58:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyelo-0000l0-VD; Thu, 02 Nov 2023 16:58:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyeln-0000kP-12 for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 16:58:27 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyelm-0007vk-P6 for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 16:58:26 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qyemL-0001eD-R8 for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 16:59:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Nov 2023 20:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66902 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16989587006272 (code B ref -1); Thu, 02 Nov 2023 20:59:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Nov 2023 20:58:20 +0000 Original-Received: from localhost ([127.0.0.1]:56278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyelc-0001d2-H6 for submit@debbugs.gnu.org; Thu, 02 Nov 2023 16:58:20 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:34808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyelX-0001ch-UB for submit@debbugs.gnu.org; Thu, 02 Nov 2023 16:58:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyekt-0000YF-7R for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 16:57:31 -0400 Original-Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyekr-0007pf-H9 for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 16:57:30 -0400 Original-Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32faea0fa1fso612712f8f.1 for ; Thu, 02 Nov 2023 13:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698958647; x=1699563447; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=xivJ+t+0dYqWpDpUXSc2gbRp+Gdg53mLvt2yuBslZlQ=; b=XOviTX1klpyPG5RoSHBTkPXspXJRwf+VXpw+nJKEx13ioQS7N5CRCXl8bOcK38BPZD fOOhQP4VBKhtuqprzQIxkB8/flxEzbXEkagYKrO0ECuemeXdyZUXldvGrEp3KKQtWxJj hTwPgbVgHKKY+FF6zINqQxUv/R3RJ2vkpMR1EtC3L5qaI0s8C6Fvtzif3oGEtEsC20oQ /Oy78ttBWa9c9VK7UadsQjL4cf0nEmaZVxacfVggbx7f8NRsI+n+JHdub9Fej9hLB/E/ vLiD/x0XIqQJ4qqb0thYdbgIZpWeRGQQspdJVLNxULu7WG+lSfZ32I0FTLNYAV3zrh1I 2czQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698958647; x=1699563447; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xivJ+t+0dYqWpDpUXSc2gbRp+Gdg53mLvt2yuBslZlQ=; b=W5vRYggaxXozO858MpFEGVbq/ckujh1prLnzfIw3q476sGnQxZhXcEa9Oslwdfsyzx WvDrryAo1W3uJPVjk6Aixr/IdN8p39RTOfqHkGp8dITNK9NIe5uOpwVEErY0tmSA52PR EsA5O4ToPY6V3c1YFMTG94W46J/IfxHGZlnFh6XQbdG6NGHvCV2+3ENkNikwRnEtCArL JxnRIwI1MThcsTqsno3LyuukIdzDmO1N7GfGoTE5qqRbaNq+2UG0GHKcJI/A0H2Tt5vU FVgkeb9ASkeGD4IlELDypiwRc4PyIqKFOaLu3apzrI2LaIGFHGgBw3L4C2E5Pq9aujbg J73w== X-Gm-Message-State: AOJu0YwVeqcxpYOHJdkPw5ydZs7mkPN9MiC+A4oVzpwjMFoalcwX7cVp 4ncrR5sby/VK6edCJ27bK2c1eoTVgsLgtA== X-Google-Smtp-Source: AGHT+IFn4vh92j7+Iaup2BqRUA8Uvvr1MrxqHIIxJ7WFLcEEXXv2wSUdDUXFKZRbD7kb493/3IJHBw== X-Received: by 2002:a05:6000:400e:b0:32d:d4c5:272b with SMTP id cp14-20020a056000400e00b0032dd4c5272bmr1047872wrb.26.1698958647069; Thu, 02 Nov 2023 13:57:27 -0700 (PDT) Original-Received: from hirondell ([2001:861:38ca:5f70:fbf3:46e1:8835:b97b]) by smtp.gmail.com with ESMTPSA id d5-20020adff2c5000000b0032da6f17ffdsm272035wrp.38.2023.11.02.13.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 13:57:26 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=kevin.legouguec@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273678 Archived-At: --=-=-= Content-Type: text/plain 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 . --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=files.diff 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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=3DVALUE]... 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=E2=80=A6 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=3D/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 --=-=-=--