From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailrelay.tu-berlin.de (mailrelay.tu-berlin.de [130.149.7.70]) by sourceware.org (Postfix) with ESMTPS id 1F2723858CDB for ; Thu, 4 Apr 2024 08:52:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F2723858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=campus.tu-berlin.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=campus.tu-berlin.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1F2723858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=130.149.7.70 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712220770; cv=none; b=cTDukJek6z7MmKNE9JP48PIlP9aJclGPBpQpIBfAw634cIzO5LKi66rOSsmTycAnVPZDbQIlLwIjTw2EFtZTT4/m9Sg2o+b09VQIG6eVziljQrsgqi61z7Qn17OIqyEPJpIl+YepMCbhX2aaDsgnNAcgKKQWh0GjsLAs7f7ZLKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712220770; c=relaxed/simple; bh=Ppn3HC0Q9trBhcAM/r3xJMbDSBYg31cXzqqZ3VkgMcg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=FTtXjO6hlfErDVn9mVZKmWmoQr2ezsaVnPny65WFi/CxTvSlOdFbdbZbPvkEQe7WXyYFK0zJ87jsl0Pf5wiS2/SOI/fLfjuCmSddUvtjxf0BsK+4rYIRZA7ufTmYJyl3n6KwuJQCCyObPQXwdxnfKS7tvxZ2v5IWfDmn040+Rn8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tu-berlin.de; l=3211; s=dkim-tub; t=1712220768; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=J6w5Spr55Tuq5otVBaEsBIr4pV//05J3zjqUtxB57aA=; b=hAxgU+B4vzbOXMGqBg/lCK9pIdadw8HqxEJ2sHG+tHO3UPx0VR+8p9gZ odAGJsI0I4rfuGr0OJ/d8nrcHMGry7lBzJLL+G8Go09KyPgPvZmV/yK2c 7E++Ynf0yICTuugWCU4wH8L83WwJ1HqWBVACBuaq/pFMcERGr2gn18ZS1 E=; X-CSE-ConnectionGUID: 2ygpamsLTey56V+z/esfvg== X-CSE-MsgGUID: wmnJ1FusR4CNqsSbxcJHXw== X-IronPort-AV: E=Sophos;i="6.07,179,1708383600"; d="scan'208";a="23401988" Received: from bulkmail.tu-berlin.de (HELO mail.tu-berlin.de) ([141.23.12.143]) by mailrelay.tu-berlin.de with ESMTP; 04 Apr 2024 10:52:46 +0200 Message-ID: Date: Thu, 4 Apr 2024 10:52:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Add wildcard matching to substitute-path rules To: Eli Zaretskii CC: References: <5ff720ec-4453-441e-ba82-84d60a2e8d50@campus.tu-berlin.de> <86o7as9ecf.fsf@gnu.org> <7eb59d60-1092-4b68-b019-d145d8fe8ab1@campus.tu-berlin.de> <867chd8yh6.fsf@gnu.org> Content-Language: en-US From: Max Yvon Zimmermann In-Reply-To: <867chd8yh6.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Thank you. >> On DOS-based systems both backslashes and forward slashes are valid path separators. So while Windows users COULD write their paths as \\path\\to\\, /path/to/ would work as well. This behavior is not new, the previous version behaved similarly. New is that to match a backslash from the GDB command line you would have to escape a backslash twice (because the CLI already unescapes backslashes). But because everyone can just continue to use forwards slashes, I think this should be fine. > > So extra \-escaping will still be needed for DOS-based filesystems. I > think this should be mentioned in the documentation. Actually, this is already mentioned in the documentation. But maybe it can be made a bit clearer. On the other hand, I really do not want to encourage the extra \-escaping. I am thinking of writing something like this instead: "On DOS-based file system, you are encouraged to use '/' as the path separator within your patterns. This avoids escaping the '\' characters and would still match against file names that use '\' as the path separator. For instance, the pattern 'C:/foo/*' would still match 'C:\foo\bar'." >> I realize now that /usr/*/include is actually a terrible example for this feature. I will change the example to avoid confusion. However it is correct that two files from distinct directories COULD accidentally get matched. But you could argue that this is already the case. Let's say we set the following two rules: >> >> set substitute-path /foo/include /mnt/include >> set substitute-path /bar/include /mnt/include >> >> Then we could run into exactly the same issue. > > The difference here is that the two lines above must be explicitly > written by the user, whereas the wildcard rule could catch another > directory unintentionally. > >> I would also like to point out that the rule selection is unaffected by this patch. To quote from the documentation: "In the case when more than one substitution rule have been defined, the rules are evaluated one by one in the order where they have been defined. The first one matching, if any, is selected to perform the substitution." > > To me, this means that the two-line example you've shown is processed > in a predictable way, by only using the first one if both match, > whereas a wildcard rule will cause unpredictable results, because the > order in which files are compared against a wildcard is undefined. > Right? No, rules that use wildcards are still processed in a predictable way. If we set the following two rules (and in that order!): set substitute-path /foo/include /path/to/foo set substitute-path /*/include /path/to/somewhere Then any file names matching '/foo/include' would be rewritten to '/path/to/foo' and NOT '/path/to/somewhere'. Even though any file name matching '/foo/include' would of course also match '/*/include'. The rule selection is entirely based on the order of their definition. Also, in the example I stated in my last reply, no file name that matches '/foo/include' would ever match '/bar/include'. The point I was trying to get across was that two unrelated files can already be mapped onto the same file (accidentally).