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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22834 invoked from network); 26 Sep 2023 21:09:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Sep 2023 21:09:16 -0000 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:From:Reply-To:Cc: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=231vDJfUa/ugYixWa3pTHVc7GvOoBIKe+YGAJ+2amlo=; b=ls3iBonMJS3PhdVYKHBEw10dYV Omoo454XeQUzZDvjga8XC/rcggiNa/HEE0RIn45kty84+1CgguhtIoBiHx+3/DziDltpxUtaWvUhN d7J0JT4VXDpaLthrylIq2AELL71z0eJTeUrsT8PUPSMffCS7uZit0DbruCuSpkPrGurkfODkFR24y 4qMiVE10F5oyVCdhVWNl1P9SZHIIq08U0GM9fKlmFkPWrvLi1amSODs4BjD2PEngEAVZZRMhW9ggo 7N49Ml4nVBfwno6fjRiShcPFzeSqmv6DDu8Il+Umw9cwaxYfbVluFD+QNY7mSOz2H9GbBCZ6k3/Nx fe/AxZbQ==; Received: by zero.zsh.org with local id 1qlFIv-000JyW-GY; Tue, 26 Sep 2023 21:09:13 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1qlFId-000Jf8-Hx; Tue, 26 Sep 2023 21:08:56 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1qlFIc-0000uT-Lr for zsh-workers@zsh.org; Tue, 26 Sep 2023 23:08:54 +0200 From: Oliver Kiddle To: Zsh workers Subject: PATCH: fix for df completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3499.1695762534.1@hydra> Date: Tue, 26 Sep 2023 23:08:54 +0200 Message-ID: <3500-1695762534.674427@ZhWD.zocD.z1rF> X-Seq: 52189 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: When trying to complete options after df, the initial - is just removed. I narrowed this down to a minimal function to reproduce the problem and it relates to the use of both -M and -U to compadd in _canonical_paths. The -M actually comes from _umountable. Matchers have no meaning when -U is used - all strings are added as matches. The patch below is to the compadd builtin option handling. If -U was specified, it simply ignores all matching controls from -M options. This does mean that with -U, invalid matchers won't produce errors. There must be an underlying problem down in addmatches() where it should be ignoring dat->match and the matchers linked list if CAF_MATCH is not set. I'm fine with it if someone wants to track down this bad logic in the matching code. The approach below does at least fix df completion and this approach saves the completion code from having to do quite a big of pointless work. _umountable also generates some bogus completions on FreeBSD for automount maps and an empty entry that comes from appending an array to a variable declared as a scalar. That results in an initial empty array element. Oliver diff --git a/Completion/Unix/Type/_umountable b/Completion/Unix/Type/_umountable index 6e4988e2d..0111555b6 100644 --- a/Completion/Unix/Type/_umountable +++ b/Completion/Unix/Type/_umountable @@ -1,6 +1,6 @@ #autoload local tmp -local dev_tmp dpath_tmp mp_tmp mline +local -a dev_tmp dpath_tmp mp_tmp mline case "$OSTYPE" in linux*) @@ -15,6 +15,7 @@ irix*) ;; freebsd*|dragonfly*) /sbin/mount | while read mline; do + [[ $mline[(w)1] = map ]] && continue dev_tmp+=( $mline[(w)1] ) mp_tmp+=( $mline[(w)3] ) done diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c index 96ad7b3f1..342611f1f 100644 --- a/Src/Zle/complete.c +++ b/Src/Zle/complete.c @@ -829,7 +829,9 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) ca_args: - if (mstr && (match = parse_cmatcher(name, mstr)) == pcm_err) { + if (mstr && (dat.aflags & CAF_MATCH) && + (match = parse_cmatcher(name, mstr)) == pcm_err) + { zsfree(mstr); zfree(dat.dpar, dparsize); return 1;