From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#65308: (find-file) botches buffer-file-name in -batch mode Date: Tue, 15 Aug 2023 14:25:16 +0300 Message-ID: <5a188f33a3580e9046a28ba6bd527ff20d54366d.camel@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31628"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.48.4 To: 65308@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 15 13:25:26 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 1qVsAw-000833-8o for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Aug 2023 13:25:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVsAa-0006T5-GM; Tue, 15 Aug 2023 07:25:04 -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 1qVsAZ-0006Sx-59 for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 07:25:03 -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 1qVsAY-0003zh-S6 for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 07:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qVsAY-00030g-Mi for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 07:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Aug 2023 11:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65308 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.169209869911554 (code B ref -1); Tue, 15 Aug 2023 11:25:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Aug 2023 11:24:59 +0000 Original-Received: from localhost ([127.0.0.1]:35091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVsAU-00030I-Sa for submit@debbugs.gnu.org; Tue, 15 Aug 2023 07:24:59 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:40598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVsAS-000300-Ib for submit@debbugs.gnu.org; Tue, 15 Aug 2023 07:24:57 -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 1qVsAL-0006Rt-MM for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 07:24:49 -0400 Original-Received: from forward102c.mail.yandex.net ([178.154.239.213]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVsAI-0003xf-Ba for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 07:24:49 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1380:0:640:6985:0]) by forward102c.mail.yandex.net (Yandex) with ESMTP id 2B1C860103 for ; Tue, 15 Aug 2023 14:24:39 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id cOdxhS4DaW20-N4WpIQAV; Tue, 15 Aug 2023 14:24:38 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692098678; bh=ujgWMJV/dBYLLyOBZa6XfR0qPxagY0UI29S1Jj59+7c=; h=Date:To:From:Subject:Message-ID; b=TPUvcLwqaxGiZxFNAXN2KrNMrwtX470m0atagqAAvPNNUlIFMm3SYPmjf4xLG1Yco +MaCbZ1aDd+i2NQ436j0266gQGFE4zAd30Wjcn4lXUgN+SLwcz7Qsw0jncM6YovqGl 4YmhHZVZfLKAg88Fo+5LC+xl9lryau4V1LvaHOm8= Authentication-Results: mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Received-SPF: pass client-ip=178.154.239.213; envelope-from=Hi-Angel@yandex.ru; helo=forward102c.mail.yandex.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:267478 Archived-At: This was found while trying to use Emacs in `-batch` mode to regexp- replace many files in a project. Turns out calling `(save-buffer)` will make it say that directory does not exist, and the reason for that is that `buffer-file-name` gets mangled filename. # Steps to reproduce $ mkdir dir && touch dir/1 dir/2 $ emacs -batch --eval '(progn (dolist (file command-line-args-left) (find-= file file) (print buffer-file-name))))' dir/1 dir/2 = =20 "/tmp/dir/1" "/tmp/dir/dir/2" ## Expected Second print would say `/tmp/dir/2` ## Actual Second print refers to non-existing `/tmp/dir/dir/2`. # Versions tested Reproducible with stable 29.1 and somewhat old master as of commit 04710bd01b2