From unknown Sun Jun 22 11:45:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs 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-GNU-PR-Keywords: To: 66902@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16989587006272 (code B ref -1); Thu, 02 Nov 2023 20:59:01 +0000 Received: (at submit) by debbugs.gnu.org; 2 Nov 2023 20:58:20 +0000 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 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 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 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 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) 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) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Date: Thu, 02 Nov 2023 21:57:25 +0100 Message-ID: <87ttq3lvpm.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= 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 --=-=-=-- From unknown Sun Jun 22 11:45:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Nov 2023 17:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 66902@debbugs.gnu.org Received: via spool by 66902-submit@debbugs.gnu.org id=B66902.169981167318641 (code B ref 66902); Sun, 12 Nov 2023 17:55:02 +0000 Received: (at 66902) by debbugs.gnu.org; 12 Nov 2023 17:54:33 +0000 Received: from localhost ([127.0.0.1]:56962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2EfI-0004qb-MU for submit@debbugs.gnu.org; Sun, 12 Nov 2023 12:54:33 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:57673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2EfF-0004qI-Od for 66902@debbugs.gnu.org; Sun, 12 Nov 2023 12:54:31 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32fa7d15f4eso2506048f8f.3 for <66902@debbugs.gnu.org>; Sun, 12 Nov 2023 09:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699811622; x=1700416422; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=YnNDP2LlR/jTosuhIHFH/sO4UP/k/VQOHPEsrobpu8Q=; b=GYzGWIpSBBB2Q/J7wfWUKkTtbUGd/WkJJTTYTeBMBQ06h8T8NKhtfEm4H2YYO5foSh TCYtwa0sd+g8tNJefH9j3xbFi+ejFCnxO6zLnTHtPwrK3NTCQPn/ME0+wnVGca/mHPna drc6uMzAGBWAfu908CbKeOvB8rh9n0HHCJKRwEK/eEdQtmnpZamF38ycH18d9I26v7Uy x4D0G4Vo/1ECTzGZ0L3u179m3/HrgkI9Ny+uFKU9+cYRsha3+vUGHlaHfnn9HdQYby3E qqTIaP6/KVaNT4WNh66n/i5meBATQm6XK5aziKtSesr/YQ35eFMhsoMzjyNUdDJ/zUuV ofBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699811622; x=1700416422; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YnNDP2LlR/jTosuhIHFH/sO4UP/k/VQOHPEsrobpu8Q=; b=eA1u06/Dp3KQqAVTl75m6Vlo/VCGMj5tcijJ6puAIMzDKN6jrMT3LF2dJlsFeeQIkf eV0RMsDiwqcE4AvaoJQINqY4NO+Hllqpllfzn8/4x5JtkxkhQZsGQO2rsVmUUESQur9R TECSQrZfNrMSBZbACfEYEnSY/zpDpcp9NBfntKBBT7JRZEVv0PgciVJNN/2sNns6iYHE dkRGeNDmT0Q+6/mi+roMopeq2mfEDNJ4IttGeouF9PzLBabCAtIZ6VHnAcO4FBen2IW5 dOfmjgnO+EyhBX3CgcR3d0KQkMPuU8Wt0vqjGuKw1nx9DgJeUb7iDepnU7hmsJRPt2bH 7mRA== X-Gm-Message-State: AOJu0YyeddrS5t3O7/Gc78DzMy6R8KM6smHoHaJOtbFHWTOzTe2ydGaV 4F7dDxwjB7Xp9PDaZQGbMy+/1nEQErVVqqfM X-Google-Smtp-Source: AGHT+IFImzbNzGl9VIyFDklZcnYqX4TBRg5YjW5PkrtzrpfA2gD/X6MsEwIICJ8OkC/YX4JRSi/IvA== X-Received: by 2002:a05:6000:1363:b0:331:4bc1:e7f with SMTP id q3-20020a056000136300b003314bc10e7fmr609915wrz.28.1699811621834; Sun, 12 Nov 2023 09:53:41 -0800 (PST) Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id k16-20020adff290000000b00323287186aasm3715662wro.32.2023.11.12.09.53.40 for <66902@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 09:53:41 -0800 (PST) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec In-Reply-To: <87ttq3lvpm.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Thu, 02 Nov 2023 21:57:25 +0100") References: <87ttq3lvpm.fsf@gmail.com> Date: Sun, 12 Nov 2023 18:53:40 +0100 Message-ID: <871qcuuacb.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable K=C3=A9vin Le Gouguec writes: > Questions before proceeding to ChangeLog entries & regression tests: For better or worse, I ended up proceeding to both these things, and then some. Let me know if the attached patches make sense; tested with make -j8 bootstrap && make -C test files-tests Tentative answers to my questions: > 1. Is this something we would like Emacs to recognize out of the box, or > is it too niche? Assuming yes. > 2. What about the more general forms shown in (info "(coreutils) env > invocation")? > > #!/usr/bin/env -[v]S[OPTION]... [NAME=3DVALUE]... COMMAND [ARGS]... Didn't go as far as handling -v nor NAME=3DVALUE pairs, but that could be added later if we ever feel like it. > 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?" Figured rx was similar to pcase in that regard: * They need to be required explicitly despite their macros being "autoloaded", because files.el is loaded during bootstrap before autoloading is set up. * Somehow that does not cause them to be preloaded? At least going by emacs -Q, * featurep returns nil, * preloaded-file-list does not include them. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-basic-tests-for-interpreter-mode-alist.patch >From 8ee71e0c70fa5c16cb802722e8de15af0932773d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 Nov 2023 10:55:24 +0100 Subject: [PATCH 1/3] Add basic tests for interpreter-mode-alist * test/lisp/files-tests.el (files-tests--check-shebang): New helper to generate a temporary file with a given interpreter line, and assert that the mode picked by 'set-auto-mode' is derived from an expected mode. Write the 'should' form so that failure reports include useful context; for example: (ert-test-failed ((should (equal (list shebang actual-mode) (list shebang expected-mode))) :form (equal ("#!/usr/bin/env -S make -f" fundamental-mode) ("#!/usr/bin/env -S make -f" makefile-mode)) :value nil :explanation (list-elt 1 (different-atoms fundamental-mode makefile-mode)))) (files-tests-auto-mode-interpreter): New test; exercise some aspects of interpreter-mode-alist. --- test/lisp/files-tests.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 3492bd701b2..233efded945 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1656,6 +1656,29 @@ files-tests-file-name-base (should (equal (file-name-base "foo") "foo")) (should (equal (file-name-base "foo/bar") "bar"))) +(defun files-tests--check-shebang (shebang expected-mode) + "Assert that mode for SHEBANG derives from EXPECTED-MODE." + (let ((actual-mode + (ert-with-temp-file script-file + :text shebang + (find-file script-file) + (if (derived-mode-p expected-mode) + expected-mode + major-mode)))) + ;; Tuck all the information we need in the `should' form: input + ;; shebang, expected mode vs actual. + (should + (equal (list shebang actual-mode) + (list shebang expected-mode))))) + +(ert-deftest files-tests-auto-mode-interpreter () + "Test that `set-auto-mode' deduces correct modes from shebangs." + (files-tests--check-shebang "#!/bin/bash" 'sh-mode) + (files-tests--check-shebang "#!/usr/bin/env bash" 'sh-mode) + (files-tests--check-shebang "#!/usr/bin/env python" 'python-base-mode) + (files-tests--check-shebang "#!/usr/bin/env python3" 'python-base-mode) + (files-tests--check-shebang "#!/usr/bin/make -f" 'makefile-mode)) + (ert-deftest files-test-dir-locals-auto-mode-alist () "Test an `auto-mode-alist' entry in `.dir-locals.el'" (find-file (ert-resource-file "whatever.quux")) -- 2.42.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Convert-auto-mode-interpreter-regexp-to-an-rx-form.patch >From d730ee2108e3bd4d641bce2cb50f61e8fbdfcd09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 Nov 2023 16:51:04 +0100 Subject: [PATCH 2/3] Convert auto-mode-interpreter-regexp to an rx form * lisp/files.el: explicitly require rx even though the macros are autoloaded, since files.el is loaded during bootstrap. (auto-mode-interpreter-regexp): re-write using rx. A subsequent patch will add support for env's -S/--split-string argument, which will complicate the pattern past my personal threshold for bare regexps. Allow multiple spaces between #!, interpreter and first argument: empirically, Linux's execve allows it. --- lisp/files.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 3d838cd3b8c..dc301bea3c5 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -30,6 +30,7 @@ (eval-when-compile (require 'pcase) + (require 'rx) (require 'easy-mmode)) ; For `define-minor-mode'. (defvar font-lock-keywords) @@ -3245,8 +3246,14 @@ inhibit-local-variables-p temp)) (defvar auto-mode-interpreter-regexp - (purecopy "#![ \t]?\\([^ \t\n]*\ -/bin/env[ \t]\\)?\\([^ \t\n]+\\)") + (purecopy + (rx-let ((ascii-blank (any " \t")) + (non-blank (not (any " \t\n")))) + (rx "#!" + (* ascii-blank) + (? (group (* non-blank) "/bin/env" + (* ascii-blank))) + (group (+ non-blank))))) "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 -- 2.42.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-Recognize-shebang-lines-that-pass-S-split-string-to-.patch >From 0287f84a3ab6b767cc99b91356a96f2162c6a099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 Nov 2023 17:46:34 +0100 Subject: [PATCH 3/3] Recognize shebang lines that pass -S/--split-string to env * lisp/files.el (auto-mode-interpreter-regexp): Add optional -S switch to the ignored group capturing the env invocation. * test/lisp/files-tests.el (files-test-auto-mode-interpreter): Add a couple of testcases; one from (info "(coreutils) env invocation"), the other from a personal project. --- lisp/files.el | 4 +++- test/lisp/files-tests.el | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index dc301bea3c5..56bdcf9d08b 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3252,7 +3252,9 @@ auto-mode-interpreter-regexp (rx "#!" (* ascii-blank) (? (group (* non-blank) "/bin/env" - (* ascii-blank))) + (* ascii-blank) + (? (or (: "-S" (* ascii-blank)) + (: "--split-string" (or ?= (* ascii-blank))))))) (group (+ non-blank))))) "Regexp matching interpreters, for file mode determination. This regular expression is matched against the first line of a file diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 233efded945..3e499fff468 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1677,6 +1677,8 @@ files-tests-auto-mode-interpreter (files-tests--check-shebang "#!/usr/bin/env bash" 'sh-mode) (files-tests--check-shebang "#!/usr/bin/env python" 'python-base-mode) (files-tests--check-shebang "#!/usr/bin/env python3" 'python-base-mode) + (files-tests--check-shebang "#!/usr/bin/env -S awk -v FS=\"\\t\" -v OFS=\"\\t\" -f" 'awk-mode) + (files-tests--check-shebang "#!/usr/bin/env -S make -f" 'makefile-mode) (files-tests--check-shebang "#!/usr/bin/make -f" 'makefile-mode)) (ert-deftest files-test-dir-locals-auto-mode-alist () -- 2.42.1 --=-=-=-- From unknown Sun Jun 22 11:45:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Nov 2023 09:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Cc: 66902@debbugs.gnu.org Received: via spool by 66902-submit@debbugs.gnu.org id=B66902.170030052330915 (code B ref 66902); Sat, 18 Nov 2023 09:43:02 +0000 Received: (at 66902) by debbugs.gnu.org; 18 Nov 2023 09:42:03 +0000 Received: from localhost ([127.0.0.1]:47818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4Hpy-00082Z-Qt for submit@debbugs.gnu.org; Sat, 18 Nov 2023 04:42:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4Hpw-000825-Hd for 66902@debbugs.gnu.org; Sat, 18 Nov 2023 04:42:01 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4Hpq-0001aZ-G5; Sat, 18 Nov 2023 04:41:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=FgrXWSvJ3FM6WqdNRr0jX3XNGlc4wKHdg3joLDSX6ns=; b=BbjsMUwIPtWLgXo5Q49L /FOE1dOI9Ccjetw46Qa1qC3ZX2/balxN035Js5NWhLFkR/7J3aDyEOOpdyFdeqJBuwLCGB9yxN+Y9 y/YbpquuE+X1wRxyjpULNtQyxFUXq6un9hlzjHc2YvhIYzshCoeqy4NS40QAO3QGU3jC3suCCUDGO OszavfvyQ/wkgN6IhIFEmWjVMCRIaKfxB7UX/2NxYZ5LrPEl3PtzIevSXpluk7LLWGCzypFEKXpC5 FNIXfPaGp1kCdxXyj+dwoNxRFsWfOdb85KUPSF/p411jx+NhwTCCNIJTrwCBLJ9MDhJCcENNVmABE kIYunRVKxWrU+w==; Date: Sat, 18 Nov 2023 11:41:52 +0200 Message-Id: <83ttpjmm8v.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <871qcuuacb.fsf@gmail.com> (message from =?UTF-8?Q?K=C3=A9vin?= Le Gouguec on Sun, 12 Nov 2023 18:53:40 +0100) References: <87ttq3lvpm.fsf@gmail.com> <871qcuuacb.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Kévin Le Gouguec > Date: Sun, 12 Nov 2023 18:53:40 +0100 > > > 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?" > > Figured rx was similar to pcase in that regard: > > * They need to be required explicitly despite their macros being > "autoloaded", because files.el is loaded during bootstrap before > autoloading is set up. > > * Somehow that does not cause them to be preloaded? At least going by > emacs -Q, > * featurep returns nil, > * preloaded-file-list does not include them. I'd prefer not to have rx required in files.el, so could you please rewrite those parts of your patch and resubmit? Also, please add a NEWS entry about the change. I think otherwise your patch is ready to go in. Thanks. From unknown Sun Jun 22 11:45:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Nov 2023 10:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 66902@debbugs.gnu.org Received: via spool by 66902-submit@debbugs.gnu.org id=B66902.17003035043379 (code B ref 66902); Sat, 18 Nov 2023 10:32:02 +0000 Received: (at 66902) by debbugs.gnu.org; 18 Nov 2023 10:31:44 +0000 Received: from localhost ([127.0.0.1]:47864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4Ic3-0000sQ-Qp for submit@debbugs.gnu.org; Sat, 18 Nov 2023 05:31:44 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:42185) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4Iby-0000s8-5u for 66902@debbugs.gnu.org; Sat, 18 Nov 2023 05:31:42 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3316d3d11e1so687801f8f.0 for <66902@debbugs.gnu.org>; Sat, 18 Nov 2023 02:31:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700303491; x=1700908291; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QVOHgVls0gNoMMmR7QqVvOO5yphxDSAobP31u4DIid4=; b=Kw+uhM/XYgq0TRy7zKpWd/CopgkcfSNId+hgnWec2JAU6WjlTJ8WcEjU3nP3xO07hC GWBG8Itra0I8c8VeoxbwXHZvL7OSUj1+R+9mfnxjLybHAtlBm+HD6bxK/gB+lQnfICtv Fd2DD4SpGbHO+PTI/1cJq7btEYKnnZyH/fyIkZw0RSYFP7pD4ywcXfFjYW5DBPxArWxE g1iweB+YM9622W9VIbQpRIkHLtOp58e/vpTQCFD3BDzQnAEGclyIsjL4Ayx1nOplECxk TZmXyR4K7lq6xgmHWOI1T4JNw82CVoKf0gWfIMjgHWhh5R/Aw8UKp7pIOonXTUv59vwJ 9XRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700303491; x=1700908291; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QVOHgVls0gNoMMmR7QqVvOO5yphxDSAobP31u4DIid4=; b=HC2uN4D6WzL1B+SvrGloaAw8XCmyH+SNx87C99cgAL42jBkXHGYTIJfZRUs30N+bLh TdS06ELa2pxZ08lZJ5ddZrE9kQIsHuue3mvp+Q/ZGy07MXaFfYJZYgNNHslLl3chY7cP plwPJ5aePwnlb49I9xECWla78NDM3rkfXGFbvtWTk5HXC1NU3fI5PX0pQxQUwJo6Ya9s l2v85fMGNz5x2P2+YME9bWfncb58drVW0UzoyDMMrI+g1WSVGbJfVgFQh3h4Uhjkjj8B AOAXZlYdeRs8DSqfamWnvHM7vcUsZYuBispHtQTf4L69IX1ZnNavB4F2ghuCI0z08EdQ lIwQ== X-Gm-Message-State: AOJu0YzHR7mBZAKjzUTOq5LMwiYoWOw6rbgL/bKfj8BFt4yJoKnXDG1o NEXysjoklC8dytD0Wr/2whA3U2MODe4XQNDH X-Google-Smtp-Source: AGHT+IFTe6XEzEA4qcECkNNAL6sqUj2gRs18hNTdeCBIM81ygRGpYjlT12dfwlQlkFS0aBAxDYe67g== X-Received: by 2002:a5d:6c65:0:b0:32d:d973:b546 with SMTP id r5-20020a5d6c65000000b0032dd973b546mr6601237wrz.0.1700303490720; Sat, 18 Nov 2023 02:31:30 -0800 (PST) Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id z18-20020a5d4c92000000b00331424a1266sm4973061wrs.84.2023.11.18.02.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 02:31:30 -0800 (PST) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec In-Reply-To: <83ttpjmm8v.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 18 Nov 2023 11:41:52 +0200") References: <87ttq3lvpm.fsf@gmail.com> <871qcuuacb.fsf@gmail.com> <83ttpjmm8v.fsf@gnu.org> Date: Sat, 18 Nov 2023 11:31:29 +0100 Message-ID: <8734x3cpz2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> From: K=C3=A9vin Le Gouguec >> Date: Sun, 12 Nov 2023 18:53:40 +0100 >>=20 >> > 3. Assuming we do want to amend that regexp, would it be possible to u= se >> > 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?" >>=20 >> Figured rx was similar to pcase in that regard: >>=20 >> * They need to be required explicitly despite their macros being >> "autoloaded", because files.el is loaded during bootstrap before >> autoloading is set up. >>=20 >> * Somehow that does not cause them to be preloaded? At least going by >> emacs -Q, >> * featurep returns nil, >> * preloaded-file-list does not include them. > > I'd prefer not to have rx required in files.el, so could you please > rewrite those parts of your patch and resubmit? Also, please add a > NEWS entry about the change.=20=20 ACK; will get to it in the coming days. > I think otherwise your patch is ready to > go in. > > Thanks. Thank you for the review! From unknown Sun Jun 22 11:45:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Nov 2023 17:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 66902@debbugs.gnu.org Received: via spool by 66902-submit@debbugs.gnu.org id=B66902.170032945827657 (code B ref 66902); Sat, 18 Nov 2023 17:45:02 +0000 Received: (at 66902) by debbugs.gnu.org; 18 Nov 2023 17:44:18 +0000 Received: from localhost ([127.0.0.1]:49454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4PMg-0007C0-B8 for submit@debbugs.gnu.org; Sat, 18 Nov 2023 12:44:18 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:58631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4PMd-0007Bi-06 for 66902@debbugs.gnu.org; Sat, 18 Nov 2023 12:44:16 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40842752c6eso4697455e9.1 for <66902@debbugs.gnu.org>; Sat, 18 Nov 2023 09:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700329448; x=1700934248; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6tLe8O37ecY8IgGgmQq2bikp1spHrVDd9uRBTjSZ9CA=; b=Onr1MZBPj1V9/Np9x9oD3jxRTyTDUAkupIh5R6sbKB5SxQWe4QdP1305vYczkIQfpV bkin/NETACfDpMUMo//nx3frayDXhPpBmi76gp+VWEGsHm9lMtRgkvhUE+3MvSrBtAoJ BPPYDUZvAQg5QimGBv+O0G1JeMJXWclWNRNg8EnaF+53MH3zjR4OD5Jt5xa5/pAAM9bA vnawLi4pbUSXgNbQJyn3ZKcAdUNa4NyABGb0w3F7TBYQK7V7D3WmWFfnkYHAiYq9pjmx jLBaN1NRqva/1LQb9fMWa5zT/QpdshHokuzjkcgnrsBEEb3wLdVH3Vf7L9Eh64rcqzjf K95w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700329448; x=1700934248; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6tLe8O37ecY8IgGgmQq2bikp1spHrVDd9uRBTjSZ9CA=; b=bXkf2Z5gVYcjRFXU1UhrnxGf4PvJ/K/u2QF47XIdH62VEZ2TuAFrZZFabaxFTCmQAT RSvg/FdCn6Q4F2nqJI4JRiaMSTvTLI8vonk7GCmvXxaU/Z+7PcIkQnHzogwJsttwCtHG VVJ7p+cRd+0qvaZhPRBI0CUwhr4VF/ifGmxkD4p0QwVXRaxIFAzzw77zZyuwLT6YrvBP We5ZtS2LV+l7OJmP0IR4Iet3pX+kQWhrvPgsTrX43v6/qCvQp9NbaK0KJiBqzuV5YPRo K/32ZC5GBsCAQ59E+TKr2gDN+ahDq2jrUdh9rLUYI8sjIbYMf+Rd2VuZ+JEfYYRMMdW3 vebA== X-Gm-Message-State: AOJu0YyfNA+fZDKvoL7AnlhEF/h5MaM6H8vB1kNmbmVuP+Kdo5kXxWwk mNzmWULQAiYDVIje1ceO0y51sFIhBbIrebrG X-Google-Smtp-Source: AGHT+IERppNBj92q3aWO8L57GqZxuLbFAmHdU3+932U3xZnc7EPUyOIM1r0A9Lfumv6O6fcc9vkJ7w== X-Received: by 2002:a05:600c:1c96:b0:405:336b:8307 with SMTP id k22-20020a05600c1c9600b00405336b8307mr2276474wms.7.1700329447468; Sat, 18 Nov 2023 09:44:07 -0800 (PST) Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id b8-20020a5d45c8000000b003142e438e8csm5839631wrs.26.2023.11.18.09.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 09:44:06 -0800 (PST) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec In-Reply-To: <8734x3cpz2.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Sat, 18 Nov 2023 11:31:29 +0100") References: <87ttq3lvpm.fsf@gmail.com> <871qcuuacb.fsf@gmail.com> <83ttpjmm8v.fsf@gnu.org> <8734x3cpz2.fsf@gmail.com> Date: Sat, 18 Nov 2023 18:44:06 +0100 Message-ID: <87wmufardl.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable K=C3=A9vin Le Gouguec writes: > Eli Zaretskii writes: > >> I'd prefer not to have rx required in files.el, so could you please >> rewrite those parts of your patch and resubmit? Also, please add a >> NEWS entry about the change.=20=20 > > ACK; will get to it in the coming days. s/days/hours/ I left a 'concat' in, because (a) it lets us interleave comments (b) the byte-compiler seems to smartly condense it all to one big string literal anyway. (Though if files.el is preloaded, everything happens at build-time and the .elc does not matter much, IIUC?) Let me know if we would prefer a plain raw string literal. Added a NEWS entry (under =C2=A7 'Changes in Emacs 30.1 / Miscellaneous', assuming 'master'); added a bug reference; squashed it all. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Recognize-shebang-lines-that-pass-S-split-string-to-.patch >From 95068836b5970c1aebb088e987741ad316007b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 12 Nov 2023 10:55:24 +0100 Subject: [PATCH] Recognize shebang lines that pass -S/--split-string to env (bug#66902) * etc/NEWS: announce the change. * lisp/files.el (auto-mode-interpreter-regexp): Add optional -S switch to the ignored group capturing the env invocation. Allow multiple spaces between #!, interpreter and first argument: empirically, Linux's execve accepts that. * test/lisp/files-tests.el (files-tests--check-shebang): New helper to generate a temporary file with a given interpreter line, and assert that the mode picked by 'set-auto-mode' is derived from an expected mode. Write the 'should' form so that failure reports include useful context; for example: (ert-test-failed ((should (equal (list shebang actual-mode) (list shebang expected-mode))) :form (equal ("#!/usr/bin/env -S make -f" fundamental-mode) ("#!/usr/bin/env -S make -f" makefile-mode)) :value nil :explanation (list-elt 1 (different-atoms fundamental-mode makefile-mode)))) (files-tests-auto-mode-interpreter): New test; exercise some aspects of interpreter-mode-alist. --- etc/NEWS | 6 ++++++ lisp/files.el | 12 ++++++++++-- test/lisp/files-tests.el | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 12ae8058cb1..b9ee3747040 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -233,6 +233,12 @@ to enter the file you want to modify. It can be used to customize the look of the appointment notification displayed on the mode line when 'appt-display-mode-line' is non-nil. +--- +*** Emacs now recognizes shebang lines that pass -S/--split-string to env. +When visiting a script that invokes 'env -S INTERPRETER ARGS...' in +its shebang line, Emacs will now skip over 'env -S' and deduce the +major mode based on the interpreter. + ** Emacs Server and Client --- diff --git a/lisp/files.el b/lisp/files.el index d729bdf8c25..1cdcec23b11 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3245,8 +3245,16 @@ inhibit-local-variables-p temp)) (defvar auto-mode-interpreter-regexp - (purecopy "#![ \t]?\\([^ \t\n]*\ -/bin/env[ \t]\\)?\\([^ \t\n]+\\)") + (purecopy + (concat + "#![ \t]*" + ;; Optional group 1: env(1) invocation. + "\\(" + "[^ \t\n]*/bin/env[ \t]*" + "\\(?:-S[ \t]*\\|--split-string\\(?:=\\|[ \t]*\\)\\)?" + "\\)?" + ;; Group 2: interpreter. + "\\([^ \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 diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 3492bd701b2..3e499fff468 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1656,6 +1656,31 @@ files-tests-file-name-base (should (equal (file-name-base "foo") "foo")) (should (equal (file-name-base "foo/bar") "bar"))) +(defun files-tests--check-shebang (shebang expected-mode) + "Assert that mode for SHEBANG derives from EXPECTED-MODE." + (let ((actual-mode + (ert-with-temp-file script-file + :text shebang + (find-file script-file) + (if (derived-mode-p expected-mode) + expected-mode + major-mode)))) + ;; Tuck all the information we need in the `should' form: input + ;; shebang, expected mode vs actual. + (should + (equal (list shebang actual-mode) + (list shebang expected-mode))))) + +(ert-deftest files-tests-auto-mode-interpreter () + "Test that `set-auto-mode' deduces correct modes from shebangs." + (files-tests--check-shebang "#!/bin/bash" 'sh-mode) + (files-tests--check-shebang "#!/usr/bin/env bash" 'sh-mode) + (files-tests--check-shebang "#!/usr/bin/env python" 'python-base-mode) + (files-tests--check-shebang "#!/usr/bin/env python3" 'python-base-mode) + (files-tests--check-shebang "#!/usr/bin/env -S awk -v FS=\"\\t\" -v OFS=\"\\t\" -f" 'awk-mode) + (files-tests--check-shebang "#!/usr/bin/env -S make -f" 'makefile-mode) + (files-tests--check-shebang "#!/usr/bin/make -f" 'makefile-mode)) + (ert-deftest files-test-dir-locals-auto-mode-alist () "Test an `auto-mode-alist' entry in `.dir-locals.el'" (find-file (ert-resource-file "whatever.quux")) -- 2.42.1 --=-=-=-- From unknown Sun Jun 22 11:45:00 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Subject: bug#66902: closed (Re: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs) Message-ID: References: <83a5rakt2l.fsf@gnu.org> <87ttq3lvpm.fsf@gmail.com> X-Gnu-PR-Message: they-closed 66902 X-Gnu-PR-Package: emacs Reply-To: 66902@debbugs.gnu.org Date: Sun, 19 Nov 2023 09:11:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1700385062-18021-1" This is a multi-part message in MIME format... ------------=_1700385062-18021-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #66902: 30.0.50; Recognize env -S/--split-string in shebangs which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 66902@debbugs.gnu.org. --=20 66902: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66902 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1700385062-18021-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 66902-done) by debbugs.gnu.org; 19 Nov 2023 09:10:07 +0000 Received: from localhost ([127.0.0.1]:49921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4dod-0004fB-7a for submit@debbugs.gnu.org; Sun, 19 Nov 2023 04:10:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4doa-0004eS-Pn for 66902-done@debbugs.gnu.org; Sun, 19 Nov 2023 04:10:06 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4doU-0002Hx-2r; Sun, 19 Nov 2023 04:09:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=DFBJmJ7U/3T+j7CSgcrL8RMsUvJzp0pJVmdmIdnQiT8=; b=gdmlC7O/Dg9Yjt/XzGat jTErEsnhHShkzBJN5w1eJWG7iwF6179mSXa6je6VUaHm0NaDQDWRWTM4XnJcvTyf3G75qtAHw81Hu Gs3G2cAxDggf25JlpJENT772R86e/gcafQponTXBoO/j5u4rOgpYX9j18xHVkYZGZJi5SmTc/oiSU UpZwlN8AUSPepG0pBX1PzyK4xIwMm/sooUYV6T9NIkAvGOFoAfRQ0M1aekVW3QTu5/VbYJRMFU803 lGHJya9wMtrbC4cwWIqvnRQ5jeLaDXUOFEN9lhwNGSNVkioKKGtbkSYj21cTTnf3i9bZze/63Cv54 zAM4XKh68TwWFw==; Date: Sun, 19 Nov 2023 11:09:38 +0200 Message-Id: <83a5rakt2l.fsf@gnu.org> From: Eli Zaretskii To: =?utf-8?Q?K=C3=A9vin?= Le Gouguec In-Reply-To: <87wmufardl.fsf@gmail.com> (message from =?utf-8?Q?K=C3=A9vin?= Le Gouguec on Sat, 18 Nov 2023 18:44:06 +0100) Subject: Re: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs References: <87ttq3lvpm.fsf@gmail.com> <871qcuuacb.fsf@gmail.com> <83ttpjmm8v.fsf@gnu.org> <8734x3cpz2.fsf@gmail.com> <87wmufardl.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66902-done Cc: 66902-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Kévin Le Gouguec > Cc: 66902@debbugs.gnu.org > Date: Sat, 18 Nov 2023 18:44:06 +0100 > > Kévin Le Gouguec writes: > > > Eli Zaretskii writes: > > > >> I'd prefer not to have rx required in files.el, so could you please > >> rewrite those parts of your patch and resubmit? Also, please add a > >> NEWS entry about the change. > > > > ACK; will get to it in the coming days. > > s/days/hours/ > > I left a 'concat' in, because (a) it lets us interleave comments (b) the > byte-compiler seems to smartly condense it all to one big string literal > anyway. (Though if files.el is preloaded, everything happens at > build-time and the .elc does not matter much, IIUC?) > > Let me know if we would prefer a plain raw string literal. > > Added a NEWS entry (under § 'Changes in Emacs 30.1 / Miscellaneous', > assuming 'master'); added a bug reference; squashed it all. Thanks, installed on the master branch, and closing the bug. ------------=_1700385062-18021-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 2 Nov 2023 20:58:20 +0000 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 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 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 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 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) 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) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: bug-gnu-emacs@gnu.org Subject: 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="=-=-=" 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-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= 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 --=-=-=-- ------------=_1700385062-18021-1-- From unknown Sun Jun 22 11:45:00 2025 X-Loop: help-debbugs@gnu.org Subject: bug#66902: 30.0.50; Recognize env -S/--split-string in shebangs Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Nov 2023 10:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66902 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 66902-done@debbugs.gnu.org Received: via spool by 66902-done@debbugs.gnu.org id=D66902.170039109228951 (code D ref 66902); Sun, 19 Nov 2023 10:52:01 +0000 Received: (at 66902-done) by debbugs.gnu.org; 19 Nov 2023 10:51:32 +0000 Received: from localhost ([127.0.0.1]:50095 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4fOm-0007Ws-9K for submit@debbugs.gnu.org; Sun, 19 Nov 2023 05:51:32 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:57770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r4fOi-0007WZ-Cq for 66902-done@debbugs.gnu.org; Sun, 19 Nov 2023 05:51:31 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-407da05f05aso7296725e9.3 for <66902-done@debbugs.gnu.org>; Sun, 19 Nov 2023 02:51:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700391081; x=1700995881; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tsr5q5IEhLa9NiomVmnAn8BTEYjHRgmpCdMl2KmzyQU=; b=QYjwZ8Au1yjlTxB+duhg4OsY4+yRh2+xXGLekKWhmKMjUENPCOrntT/DNSMsIZUSRY 92v6u8QieHfLOOkmuMmqAeTrDs+qVdtmiSiQXevw35pL8HBUPhPhI1ImPZUu1rHN4H4J vKj43tSe5Fg3A7iusfw96c3ChSKcw9JJVtC2yo2B9UofBpbdTG3AkspPd4r1NkTkxXOZ Va27kYMPbjX7MnzBZmPh6/lF6STRHmADsM1mb5HYAIfrXWcvnEaqSoszlRFR00vEjR9o Re7fEeZjpzg4MBYAYpHP/bOgRyQ2rj3rpUkw7Vh5YV+APPmtj4nXuNucydDHy2rJi7wm 0d4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700391081; x=1700995881; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Tsr5q5IEhLa9NiomVmnAn8BTEYjHRgmpCdMl2KmzyQU=; b=whZrbZ8lsmonjZGiNm/bGNhEbbIP6SNBKK4LgiKWNlVmd1cBOBSu0okwVLjfYtX+di X5bSmoDNeT0rg5Dnt/nVk+sBvZ5sMBY5N9RI/hag5g5XFUOHd/4/a/bfkf8mlu7NPtiU 95+Lmvv4yecJM0malUx4LzLeVFr9DL37+XsV19wq3Ra7etEmGo77CklV4PqPPtNyH/jK ZDZKDUysRtfBCY0GRgl4kH4qscWYxKU5Q13qUJMOySRpDliICY4FCxYoeJYX5ibJkvMI CReixy+XogftzrRgNYHkS4qLOrOC7qSKZbLX35gav5G4DnBRjmoziYtvCewM+Wctbowy Ea0A== X-Gm-Message-State: AOJu0Yx4+cLvRXBFtn/ArvwjqYc0VvBqqVefo06Dbg8PixeayCDbZft7 Ab9jji9E4T8bcnkpXMbPPDLKPnlrLdxNOqMQ X-Google-Smtp-Source: AGHT+IFeHXCyTC/4TKcwXIgs9QgXAujqhs9Z1mF9Z5L5eDUA3pn80pAkV2Vlg3lyDGQ+sus4b6ODCQ== X-Received: by 2002:a05:600c:548c:b0:408:403a:34dc with SMTP id iv12-20020a05600c548c00b00408403a34dcmr3467415wmb.37.1700391080756; Sun, 19 Nov 2023 02:51:20 -0800 (PST) Received: from amdahl30 ([2a01:e0a:253:fe0:2ef0:5dff:fed2:7b49]) by smtp.gmail.com with ESMTPSA id p19-20020a05600c05d300b004081a011c0esm13509592wmd.12.2023.11.19.02.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 02:51:20 -0800 (PST) From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec In-Reply-To: <83a5rakt2l.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 19 Nov 2023 11:09:38 +0200") References: <87ttq3lvpm.fsf@gmail.com> <871qcuuacb.fsf@gmail.com> <83ttpjmm8v.fsf@gnu.org> <8734x3cpz2.fsf@gmail.com> <87wmufardl.fsf@gmail.com> <83a5rakt2l.fsf@gnu.org> Date: Sun, 19 Nov 2023 11:51:19 +0100 Message-ID: <8734x210ew.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: > Thanks, installed on the master branch, and closing the bug. Thanks for all that, and the copyedit =F0=9F=99=8F