From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 14 03:36:37 2022 Received: (at submit) by debbugs.gnu.org; 14 Sep 2022 07:36:37 +0000 Received: from localhost ([127.0.0.1]:53565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYMwn-0004a1-9D for submit@debbugs.gnu.org; Wed, 14 Sep 2022 03:36:37 -0400 Received: from lists.gnu.org ([209.51.188.17]:35122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYMwk-0004Zr-RL for submit@debbugs.gnu.org; Wed, 14 Sep 2022 03:36:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oYMwk-0003ZN-KW for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2022 03:36:34 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]:35488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oYMwj-0006Qy-2Z for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2022 03:36:34 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1225219ee46so38748125fac.2 for ; Wed, 14 Sep 2022 00:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date; bh=g4IvtXavxJIIVHkCprscjHVMv7PgYEgemH0Nn7v6fok=; b=lPJ8tEySwKSMNkUfG4nAv1zDYzQmhfkDfqJuxBAus+F3YtrIZz2sxetF+MUN847pZC w+SAb7MitLLSd0M3WMUhBVlSJ/wZ2JeKINIKbC0P1cyF4yjrxABQGEMpUAtBFhl4lvBK z5VmkUWbpUYdbx/iRjRCNJ3djiYyncrmserghDdhy2OcHBQVBqHzGxeoUIqePGwwdg2B mz0JssZl3PHcRRx9z4Ncd/KT+4CRUytGfB+oNuorfxlJLbkjC0eE0ROyAl9CT/1xV/RP yj0vmnOghaGDqPKERAfSNsIc1+r6EE5vojGyuof3W62+r/stEwtbLvgs6bq83AtguVDZ 5QFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date; bh=g4IvtXavxJIIVHkCprscjHVMv7PgYEgemH0Nn7v6fok=; b=zrNdgI2ymkC9z6zLX1GNyg/O4vT/25QjnOptTMrsuntW2ZjpRiWu2lgX3n+uzh3U8D LccSLcyY3wDBWHYDGGlsfLZRgQTIQP6XkDcwQvSfpyryVFRttTYZSCekczrDcvq6w/NR dYlN+UNqHnHKbOV+rIJlR/qWQP1m9e9XI1TfpkrI/nfMZMjvzkF0hbFmGC8CZWg179Ru 2Xtj3nr5Y1XXF8kVuU2WQzLgURc2B4CFUzhfHoAytlcWIk0AxuMVgaQSLaKakr8umnxn DG0mrUtirbILjJGji7orczxaZl0TFYFQDbEKxEDTftW5DSyl+h5yU66qMPWZWe3r2T6T wI7w== X-Gm-Message-State: ACgBeo1+6ewqwrMjoDU+1EVWbu8thfBUJJCvdXu6Q5EigJht8+ooB8Wd 9vafU+fGH7KQKc2b/e6NZxj4NItGXviq7Rjg2DvtRS83 X-Google-Smtp-Source: AA6agR6VmbqeyY47anJPPE1OJ3CbgSIep5ZZu4OvpUlGaHZL81VBF9bQ6OLyzCOiItHwGk8DZyRCXYGQKU38fIqPzLg= X-Received: by 2002:a05:6870:538c:b0:11b:e64f:ee1b with SMTP id h12-20020a056870538c00b0011be64fee1bmr1540760oan.92.1663140991237; Wed, 14 Sep 2022 00:36:31 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 14 Sep 2022 00:36:30 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Wed, 14 Sep 2022 00:36:30 -0700 Message-ID: Subject: FIXME about save-match-data in shell-command To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=stefankangas@gmail.com; helo=mail-oa1-x2f.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.3 (-) 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: -2.3 (--) Severity: wishlist In `shell-command', we have the following comment: ;; Preserve the match data in case called from a program. ;; FIXME: It'd be ridiculous for an Elisp function to call ;; shell-command and assume that it won't mess the match-data! I think we should decide to either get rid of the FIXME, or to take the plunge and remove `save-match-data'. (Note that the latter has been there since 1995.) From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 14 09:25:46 2022 Received: (at 57795) by debbugs.gnu.org; 14 Sep 2022 13:25:46 +0000 Received: from localhost ([127.0.0.1]:54166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYSOg-0003fh-DS for submit@debbugs.gnu.org; Wed, 14 Sep 2022 09:25:46 -0400 Received: from quimby.gnus.org ([95.216.78.240]:48984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYSOe-0003fT-PI for 57795@debbugs.gnu.org; Wed, 14 Sep 2022 09:25:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0u/w2mqkdUTpYQMQB4NW6JJwtxjfbGuoCmerMz1CQT8=; b=J0Xa73/bRNkYMx+vJdkKSk7fYY h9eDZg0hliJrCprUt00nTsOiQxbqFnUKx0rGX/lyzr9prV3B40VixFbICW3Xm/UWk2s5kBBsiZ6Nf YEGMZwHecQsuCZ4eY4SpEfQXhETc18jynK/C3OmWdV/NR6IEn/qln0hN90NGXhZGoaiw=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYSOV-0006qE-O5; Wed, 14 Sep 2022 15:25:37 +0200 From: Lars Ingebrigtsen To: Stefan Kangas Subject: Re: bug#57795: FIXME about save-match-data in shell-command In-Reply-To: (Stefan Kangas's message of "Wed, 14 Sep 2022 00:36:30 -0700") References: X-Now-Playing: Joan as Police Woman's _Joanthology (3)_: "The Classic (Live at the BBC)" Date: Wed, 14 Sep 2022 15:25:35 +0200 Message-ID: <87o7vi84vk.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stefan Kangas writes: > In `shell-command', we have the following comment: > > ;; Preserve the match data in case called from a program. > ;; FIXME: It'd be ridiculous for an Elisp function to call > ;; shell-command and a [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 57795 Cc: 57795@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 (---) Stefan Kangas writes: > In `shell-command', we have the following comment: > > ;; Preserve the match data in case called from a program. > ;; FIXME: It'd be ridiculous for an Elisp function to call > ;; shell-command and assume that it won't mess the match-data! > > I think we should decide to either get rid of the FIXME, or to take the > plunge and remove `save-match-data'. (Note that the latter has been > there since 1995.) Hm -- I originally thought that removing that save-match-data would lead to subtle errors in callers that depend on this behaviour. But... there's also code like (let ((handler (find-file-name-handler (directory-file-name default-directory) 'shell-command))) (if handler (funcall handler 'shell-command command output-buffer error-buffer) (if (and output-buffer (not (string-match "[ \t]*&[ \t]*\\'" command)) before that save-match-data, so the match data will be overwritten in many cases anyway. The code was (originally in 1991): +(defun shell-command (command &optional flag) + "Execute string COMMAND in inferior shell; display output, if any. +If COMMAND ends in ampersand, execute it asynchronously. + +Optional second arg non-nil (prefix arg, if interactive) +means insert output in current buffer after point (leave mark after it). +This cannot be done asynchronously." + (interactive (list (read-string "Shell command: " last-shell-command) + current-prefix-arg)) + (if flag + (progn (barf-if-buffer-read-only) + (push-mark) + ;; We do not use -f for csh; we will not support broken use of + ;; .cshrcs. Even the BSD csh manual says to use + ;; "if ($?prompt) exit" before things which are not useful + ;; non-interactively. Besides, if someone wants their other + ;; aliases for shell commands then they can still have them. + (call-process shell-file-name nil t nil + "-c" command) + (exchange-point-and-mark)) + ;; Preserve the match data in case called from a program. + (let ((data (match-data))) And here we see that the command does really preserve the match data in all circumstances -- but that has been lost over the years. So I think removing the save-match-data should probably not lead to any regressions, so I've now removed it. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 14 09:26:54 2022 Received: (at control) by debbugs.gnu.org; 14 Sep 2022 13:26:54 +0000 Received: from localhost ([127.0.0.1]:54170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYSPm-0003hL-0A for submit@debbugs.gnu.org; Wed, 14 Sep 2022 09:26:54 -0400 Received: from quimby.gnus.org ([95.216.78.240]:49014) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oYSPj-0003h3-Pv for control@debbugs.gnu.org; Wed, 14 Sep 2022 09:26:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=uoIdfZNiqwrFAqyesIE+Oa0bLfYa1rnzc1pIRbQ21PA=; b=qfLpPo25C9fH7uzMsCKtnFHcti aa7NjMZ1prvnuh+AEJPLXdM3R2+rV/jfSBHgU49kG54GmQeSlVIKzLpAVcsg5ssdsvI/R3ZBwRySb 3xxSjVs8Tq90S17+9UtCTLJsrERf3e6Wc+GpvhXScYHFCBozLtNmuLw8tdKlzhBD3jAg=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oYSPc-0006qi-1N for control@debbugs.gnu.org; Wed, 14 Sep 2022 15:26:46 +0200 Date: Wed, 14 Sep 2022 15:26:43 +0200 Message-Id: <87mtb284to.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #57795 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 57795 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control 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 (---) close 57795 29.1 quit From unknown Tue Jun 17 01:34:54 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 13 Oct 2022 11:24:18 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator