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#67438: 29.1; WDired uses `substitute-in-file-name', so `$$' is changed to `$' - undocumented? Date: Sat, 25 Nov 2023 10:11:11 +0200 Message-ID: <83h6ladzhc.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37518"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 67438@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 25 09:12:21 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 1r6nm1-0009ZR-9s for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Nov 2023 09:12:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6nlf-00039g-6B; Sat, 25 Nov 2023 03:11:59 -0500 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 1r6nld-00039S-HA for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 03:11:57 -0500 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 1r6nld-0001on-96 for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 03:11:57 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r6nlh-0007S0-Qh for bug-gnu-emacs@gnu.org; Sat, 25 Nov 2023 03:12:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Nov 2023 08:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67438 X-GNU-PR-Package: emacs Original-Received: via spool by 67438-submit@debbugs.gnu.org id=B67438.170089988828594 (code B ref 67438); Sat, 25 Nov 2023 08:12:01 +0000 Original-Received: (at 67438) by debbugs.gnu.org; 25 Nov 2023 08:11:28 +0000 Original-Received: from localhost ([127.0.0.1]:37715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6nl9-0007R8-Hp for submit@debbugs.gnu.org; Sat, 25 Nov 2023 03:11:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6nl6-0007Qt-UD for 67438@debbugs.gnu.org; Sat, 25 Nov 2023 03:11:25 -0500 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 1r6nkw-0001ac-64; Sat, 25 Nov 2023 03:11:14 -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=RFHhMoTb9rgcJuBYyNYofstpGFodMEpujcczimfM24Y=; b=RbElJvfMFlmygpCM+Hc5 XC2xwPhZkhUa5Hi/SJgpmgmClZAQ8EuQi4yg0qfD4RaAzddUiCUGIDKQV7hbLlJ39uUga6DhHZJYP dUSc/ok7cn5Z9QYFW1unIyzAtjHjlAc8o/ONFeCQiNeDAt1CoI4kq4LDjFaDf6fPljkzLpI2hpejL 5ki9HGm30SVGWDGMJU46jdAHENDuhrj+pZuIeck/3mF8uQuFUuAtRU+p/KrJFMqzTZpbDNqkrnv7h E5v2pHKUjDHlTxnYG5sbnZt6wBrcPPFNhj7PVWKJ49Iynnl3YqkvD3oVxYHz26rvzoV7ingrVKC63 9+be1S617DAvnQ==; In-Reply-To: (message from Drew Adams on Fri, 24 Nov 2023 23:35:54 +0000) 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:274919 Archived-At: > From: Drew Adams > Date: Fri, 24 Nov 2023 23:35:54 +0000 > > emacs -Q > > C-x d aaa ; Go to a directory with a file named `aaa' > > C-x C-q > > Append $$$$ to the file name, to give `aaa$$$$' > > C-x C-q > > The resulting file was named `aaa$$', not `aaa$$$$'. > > It seems that every occurrence of `$$' in a file name is treated as just > `$'. (The position of the `$$' in the new file name seems to be > irrelevant.) > > I see this in older Emacs releases as well. I found nothing in the doc > that would indicate that this is supposed to happen (and preferably > why). And the only occurrence of char `$' in wdired.el seems benign. > > Ah, I found it - it comes from `substitute-in-file-name': > > (substitute-in-file-name "aa$$$$") ; -> "aa$$" > > But is that appropriate behavior in this context? The $ processing is an integral part of the Emacs interpretation of file names. The Emacs user manual says in "File Names": The character ‘$’ is used to substitute an environment variable into a file name. The name of the environment variable consists of all the alphanumeric characters after the ‘$’; alternatively, it can be enclosed in braces after the ‘$’. For example, if you have used the shell command ‘export FOO=rms/hacks’ to set up an environment variable named ‘FOO’, then both ‘/u/$FOO/test.c’ and ‘/u/${FOO}/test.c’ are abbreviations for ‘/u/rms/hacks/test.c’. If the environment variable is not defined, no substitution occurs, so that the character ‘$’ stands for itself. Note that environment variables set outside Emacs affect Emacs only if they are applied before Emacs is started. To access a file with ‘$’ in its name, if the ‘$’ causes expansion, type ‘$$’. This pair is converted to a single ‘$’ at the same time that variable substitution is performed for a single ‘$’. Alternatively, quote the whole file name with ‘/:’ (*note Quoted File Names::). File names which begin with a literal ‘~’ should also be quoted with ‘/:’. You will see this behavior _everywhere_ where Emacs accepts file names from the user. For example, try: M-x rename-file RET foo RET foo$$$$ RET the resulting file name will be "foo$$", with 2 $ characters instead of 4. WDired interprets file names in the same way, and that is OK because anything else would be inconsistent. > If it is, then maybe the doc should tell you what to do if you want > literal `$' chars. It's hard to find where and how to document that in WDired's doc string, without also describing the other special processing of file names. Again, this is part of the basic file-name semantics in Emacs, so repeating it in every command that accepts file names would be excessive and unjustified.