From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65308: (find-file) botches buffer-file-name in -batch mode Date: Tue, 15 Aug 2023 15:03:15 +0300 Message-ID: <83leeca4xo.fsf@gnu.org> References: <5a188f33a3580e9046a28ba6bd527ff20d54366d.camel@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27177"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65308@debbugs.gnu.org To: Konstantin Kharlamov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 15 14:04:23 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 1qVsmd-0006sK-8u for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Aug 2023 14:04:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVsmR-00080i-4O; Tue, 15 Aug 2023 08:04:11 -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 1qVsmJ-000801-F1 for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 08:04:04 -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 1qVsmJ-0003Ux-5T for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 08:04:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qVsmI-0000nV-KR for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 08:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Aug 2023 12:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65308 X-GNU-PR-Package: emacs Original-Received: via spool by 65308-submit@debbugs.gnu.org id=B65308.16921010223033 (code B ref 65308); Tue, 15 Aug 2023 12:04:02 +0000 Original-Received: (at 65308) by debbugs.gnu.org; 15 Aug 2023 12:03:42 +0000 Original-Received: from localhost ([127.0.0.1]:35129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVsly-0000mp-DQ for submit@debbugs.gnu.org; Tue, 15 Aug 2023 08:03:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qVsls-0000mW-Pe; Tue, 15 Aug 2023 08:03:40 -0400 Original-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 1qVsln-0003LH-8f; Tue, 15 Aug 2023 08:03:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=oAuf7RTblIkJIyMtnvWlMNZsPUcFfqGzSxB/zhWEAEY=; b=MKC9bzI6N6Yf +QWmCzkp/fiBBGhdPApNMzC8954pKDuzsFqTznv+bKTx1nnvWpwIIE2zBngU+XKdcpLHSfWuyk1mZ hyvQgYYtv4wr+W04bm7bhINV5UlEzwrd1+TkqZx1onsAdxls4Eg6k299rftYI+3wKvdCa0hYraG5Y /1P2QUn9DLnxf6n+MKvT8W3AhzaLXXrLXdql9RpYDi7kgA4681IgYqMLAvgd/0Ik9/3fSvcLDRdr1 p4iNAoIoY9ATT7g8OIDkwRAK1vpSs6Sz3l/Pa8d/A1jPyHi8EKoZokO92mxl5Xml++P5DM4G3wzwP p3Nc7HeyC8Z1Y/oHwUq5BQ==; In-Reply-To: <5a188f33a3580e9046a28ba6bd527ff20d54366d.camel@yandex.ru> (message from Konstantin Kharlamov on Tue, 15 Aug 2023 14:25:16 +0300) 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:267480 Archived-At: tags 65308 notabug thanks > From: Konstantin Kharlamov > Date: Tue, 15 Aug 2023 14:25:16 +0300 > > $ 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 > > "/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`. IMO, this is the expected behavior: relative file names are interpreted relative to the current buffer's default-directory. After the first find-file, the current buffer visits the file "/tmp/dir/1", whose default-directory is "/tmp/dir/". There's no bug here. To get what you want, run the command-line arguments through expand-file-name _before_ calling find-file.