From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12108 invoked from network); 22 Jun 2023 03:55:32 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Jun 2023 03:55:32 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1687406132; b=rKwNusMCkcouSFzIpZJ/np8q7wR81yJf8/UToXkZ6gPJCwexDj8OqnRVd6mo34QYa3vXIsTq90 2bAXa4apHHUw/roynfTIqbUz0R57vSNdWCFlxE+JLChCb0FecmYuXbB6bctAtxNVL2GPKOwoiC /bEuARNCQz/r2J+gyk9iIrFMChrLVl13JDR8hrNwU+TYvJOjZS24uDL3/lAyqgERyFxC/siFiu +wtGxrl9HO++FIM5pwLjoZkPq6Z3R4/cOc01U+BDJLX6fUAKoKI0NrOyje8v2ZIW0doBLPhY/e 8FUZHV1OaGyKOgQHlILuJWrt5kiu0G3iTdBJJaFYJziUwA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f51.google.com) smtp.remote-ip=209.85.208.51; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1687406132; bh=FAuB6Tc5bXBWv+VZmfFBu5X28HOXdIgrCvBhk1RDcNc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=Ee6GNjlmldN42o/E9W2bEAaNXePEjyloxBMEcP+U2O1cLty3z2vWhZMqMsBNeYtKe1osyIw5b9 HGaJQ5m8eofDNPc4TpKCynj3P04t02lpx1TvHKAuRKYLk/pMNld8S6OuYcYNii+ddvSyb18+Nq kcAIgzOzS8NxJnqnx1w3jVMLdp40xTlIlhdNdA27izYGjHCqxrOI1kTKcTrzhfpwOEE45eXBDQ LbtQi5y4EGu4o+VNHRV8nMmz7hfjjpg3INQYl3cUyyJv0v5XguEt87oB8N/9oTbjT7se4fQs3A 35YNKYP0XpsA0pMElIO0sqBl2OKi2I6Om8IkgX/aAZqzxA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=1nH7wbr+9mvxcsgJOq5UPQFMGia0XLdBZlD7ECS9Sl8=; b=rvu/nyNZ5ivbX/X6pDWjHUgRFo tCYP8F4Y/75A/RrSr9pvrLHPffwS7U3NwXQ8SPqetU73Sr/+P830z4kt/yW+BqYrpBa7Ty812kf72 w3Qbjrnu14wkIl3tu0s1JjHCRARbEtVR4uYt803qmfvJYYcDXP9cGTt0TKT+rHdRydVN/wm+bBta1 VGAOljl8QzdvZ7Pz7SGjpo3F+JOog2YmL4x7sYQ2vN1yOdqQq7GCa2KgvXQZc8dvwsMWS299FGRrE BKetz5iAEs1yK8R1H6nzvhCS4EMp0gXYFGbWagTW8YXfX/fT4WmMUJdkJrDZfODARIzbvWVeYdz23 OY2fC5vA==; Received: by zero.zsh.org with local id 1qCBPv-0007Lo-4R; Thu, 22 Jun 2023 03:55:31 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f51.google.com) smtp.remote-ip=209.85.208.51; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ed1-f51.google.com ([209.85.208.51]:59432) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qCBPK-000700-0R; Thu, 22 Jun 2023 03:54:55 +0000 Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-51a20138617so8748763a12.2 for ; Wed, 21 Jun 2023 20:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1687406093; x=1689998093; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1nH7wbr+9mvxcsgJOq5UPQFMGia0XLdBZlD7ECS9Sl8=; b=nMlkIDux/J40tUzPONqqm2IUCVMC/oziJbdlokjGbraSgFCOSPoTxGBDqgz8eUmd5y lmkgNgNpeHwaJRUUMyPZmOCt2jg+w4i+kuoeSJHc8d5+yadcPlb7AejjtsafPiVnun4U o8du1wOippvo6OxociMgMjs/+Ovob1hVMtYr8owkmjIQoQuEs/L+alTKLT2bx19w/bS4 mE2qeKqVEEWQaUBQKSU1/z6FVSD0pMmk1F6r3hF/WvaidxnV/zF4Art70DmKqAoCWbQw 918DfOOoXpNI1CvhjYzv+gSsPUHHKZxMVZ4KA7fQoO/GUiv1USIXbcpDbHJyzI/Ww360 E1Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687406093; x=1689998093; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1nH7wbr+9mvxcsgJOq5UPQFMGia0XLdBZlD7ECS9Sl8=; b=JgOqA6hqCwQOMpLp9B+MmJ+K3XA9aWI1/CxWvohE9PdLkpNxwNVCuPsKFa/J27Xj3L aRMkFXGeoD/gna/po3YpdBrLu2kF3GBVtR2n1ISci64fcAft2wJe92xpwbRrcYnKhxvc 6jjwgg2spRJFFfDeHwrsK8UZY9B33Q24426VYbUo3yZnwF0NWoeWAzq26fNq9IwE8dC8 bE+9msYpVsRoRXB+TM2pJUn2vswu5VWueWBqUOquKj14C9PS1jiIUiSaKcT9wOiVn9TT cS1f4j90ZVyaDkiDOwA2MRrXfkCWT0j4W9AFEn4AVJ3hmCbxAjY0qUbpC85HwUW+EOi/ SGng== X-Gm-Message-State: AC+VfDwd3IFBOvhT2X//VEK1msgr0mDNM5oNIZlXuPP+w7Cm4xRDRzf6 RwAnC43r2uVUhyRKK4Ymas7x438ODlKx+Y1LPAzSSw== X-Google-Smtp-Source: ACHHUZ5dCo7lbH8tFCIct/S/TeshywCsxnxOD0keBZK1fU9LHca97mgdfl4p8AAxDAEIQ8mPkDZ7616+IBvf7Ni3xUo= X-Received: by 2002:aa7:cf86:0:b0:50b:fb85:8608 with SMTP id z6-20020aa7cf86000000b0050bfb858608mr11780476edx.25.1687406093318; Wed, 21 Jun 2023 20:54:53 -0700 (PDT) MIME-Version: 1.0 References: <6bf87a65-1730-8a21-ac5a-d7d05219e024@crans.org> In-Reply-To: <6bf87a65-1730-8a21-ac5a-d7d05219e024@crans.org> From: Bart Schaefer Date: Wed, 21 Jun 2023 20:54:42 -0700 Message-ID: Subject: Re: [bug] Completion functions _files/_path_files -F filter on escaped file names To: Johan Grande Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 51886 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Wed, Jun 21, 2023 at 12:29=E2=80=AFPM Johan Grande wro= te: > > When completion with _files or _path_files is called at the beginning of > an argument, exclusion patterns given with `-F` are applied to > already-escaped file names. This breaks patterns that contain escapable > characters such as a space or []. > > With a \ added to the pattern, 'a a' is filtered out. Upon closer examination, the documentation of the -F option is imprecise. -F is a substitute for the "ignored-patterns" zstyle, and the description of that style clearly states that it filters out trial completions. Thus the -F option does not ignore files, it ignores the strings that are candidates to be inserted on the command line when completing files. > But this is very brittle as it depends on the implementation of the > escaping instead of the file names themselves. Unfortunately this is implemented in the internals of the "compadd" builtin and other forms of completion rely on it. > Do you think that this behavior could be fixed? We could try this. However, it's not backward-compatible for people who are already quoting spaces etc. for _files -F patterns. diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_= files index d46dcbe5a..c471ad08e 100644 --- a/Completion/Unix/Type/_path_files +++ b/Completion/Unix/Type/_path_files @@ -100,6 +100,12 @@ if (( $#ignore )); then fi fi +# Adjust the patterns for the effects of "compquote" on file names. +# What's needed here is the inverse of ${(b)...}, that is, quote only +# characters that are NOT pattern characters but might need quoting. +# Backslashes appearing in a file name remain a bugaboo here. +ignore=3D( ${ignore//(#b)([\!\#\$\&[:space:];\"\'])/\\${match[1]}} ) + # If we were given no file selection option, we behave as if we were given # a `-f'.