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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2389 invoked from network); 25 May 2021 07:40:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 May 2021 07:40:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1621928408; b=pCc33V2cZpDotqXUX+7VLmlrC4Qm3KU1M6PY+rUdDXJaaRvGQe0fdB5c2Ej6DVwTkomB7YCgcY SjrOB4p1nu98nag/25Ex2xthF6FAnx5YBF8dZ1sGRelX2yCyoQOA+1OCfIzDEtbDMgt//BrRfJ /60oEpTwm07RLGGlTSOuCBsakGPAGjfY0BVRDwBLnrqe9P2hHyZHQcN5AFU7GwjDhJJWUgen1y EtPMtFqMF9cqRMnRECuh1WAyROZ202QKMbyyn9sqR5A4ywmZCKdEIR1ZafRxGnIQG76StuLw6O Q+HeA3jhk5YRvZXkYAYvvJ8xhw/9JXbOuSbo3usCWsd7pQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f182.google.com) smtp.remote-ip=209.85.166.182; dkim=pass header.d=dana.is header.s=google header.a=rsa-sha256; dmarc=pass header.from=dana.is; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1621928408; bh=yOenx7LsD9hhDpzHURJ/mGjzT5VJosQ2I66kNNYQaLQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:References:Message-ID:Content-Transfer-Encoding:Cc:Date: In-Reply-To:From:Subject:MIME-Version:Content-Type:DKIM-Signature: DKIM-Signature; b=Xukd/gtAz/xoTarwO7+SaQEmqGjKWxmUjC9BW1mEV7fGLz4vwsZ7Om7R87erdcYbxN3rdi7QVB 3pI744m0jvBczNp6uhzdbtshneIPKQZj9A/vWYjsoao1HBiqKw26TRSZV/sPFAW4X8Q3MPEX/+ wx6zrNT3kx0iEZiF+byyeGfnUFw9TvNXtpsH+npafPcGdFSBwp/z4uYZ3NgK8v79x+3xk2Fl1A 0rAFV9iENn4ETtIVVwY/j6sJGjgxnZn+Izkrc0PJIsSWgawTJOUpfb8oGtItZqvnM/bcYDJ8/2 AldZq9izBF2JMuY9Ji+2MXx6ZOj5AeA8BTgZg56+DNYcZg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=goU9ZL30JNhD9Ek33Vl776WKFYFnSO4WnNyrFPwwu/s=; b=snrF0K1L3R0TfN2gnrpdjzV2y7 9ZpMLnWF/ww6EAGzJrr0B9RKFbB3VwIGIcBTVCnZVy59oNGCUmsZGqT70BrkzyrN57LKPDFNGf9Rg TBzsHo9WRSv/FB6XvhIAl8PHVQ2Ms4s0ykzsek2/D6wdjyd7oOiwPbvIbvKpAgCh1M6s5MidQLshZ 93mtsAqL05/o0A0V/g7PJGXNd4ToFlDHZcskp+y+0er4VGlcto0kCTp1e4bSfaDzE45dxIoGcRca5 l4kjhZVLzN+dVWqHqxngMowuCI8XF7NSTm88ytvR4Lp9BbkpnJ1i8kwMv8wNCqDcLC0ZUH5l0oDNf MyFVjSOg==; Received: from authenticated user by zero.zsh.org with local id 1llRfb-0005yg-41; Tue, 25 May 2021 07:40:07 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f182.google.com) smtp.remote-ip=209.85.166.182; dkim=pass header.d=dana.is header.s=google header.a=rsa-sha256; dmarc=pass header.from=dana.is; arc=none Received: from mail-il1-f182.google.com ([209.85.166.182]:34443) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1llRez-0005gd-7P; Tue, 25 May 2021 07:39:30 +0000 Received: by mail-il1-f182.google.com with SMTP id l15so15709808ilh.1 for ; Tue, 25 May 2021 00:39:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana.is; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=goU9ZL30JNhD9Ek33Vl776WKFYFnSO4WnNyrFPwwu/s=; b=OcYqMBFWSfwcTQYdepgR4rlO8WQ/IScO/OXJY1xM7kH7mlvuS6V6Bpf0MXwUsMH1M1 mm4vQWF38hjd6x4zNluK+UkKXWFHU1cuWjlUH3SBXlYOdOw1xLFdRGYCGQaBMn1XFxMb V4IOdqX9cFlkgLg/l2zHHrXji7xtrl5P2uU3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=goU9ZL30JNhD9Ek33Vl776WKFYFnSO4WnNyrFPwwu/s=; b=nzFEb/6qK9UO9wLxVPcmUd/uKC21Thx1MNp4+qEiwgE+gf6xkgYoLtWMyyac/d7jMo lxHR/4P8hGcRdYayYKx/3/BdVvYkPSQCNPJwg++m7pZWJJZZwni7SDVRblCv92Kc1389 64umhOlh2PEJCvLM2IUZdwzy+/plwLKgmFp2b89Ax2ONvKZFC03CwzQHOw8uE5dSB26C ssVLOwNj2efX8Qqt5PEW4a/XnrUGRuSDg0D0zUrlawYc8tq05DiFCCNnZk1CeaY0ETgK lXgPzuBdV+ia1XvXXsbKeNfJ0eWBr+K00DeT7/TVDFEIOjOnlJaGvYieNESsk6PVLZHn FeeA== X-Gm-Message-State: AOAM530SETGaEsPzhtwDZE7EKdnaFstNYY8dBO2nG9pnEh5My+0n/z9V WqFklPAIFBn1lq91q0uifHEbXg== X-Google-Smtp-Source: ABdhPJx6yXMVcVSgXneYfbcEwUEBSI9Uk7F7RgH9xof2d25xr91Bbh+3jZAdkiKz/AOPe6vJ2tbNjw== X-Received: by 2002:a05:6e02:488:: with SMTP id b8mr19912968ils.152.1621928367832; Tue, 25 May 2021 00:39:27 -0700 (PDT) Received: from heartswap.lan.dana.is (173-17-84-59.client.mchsi.com. [173.17.84.59]) by smtp.gmail.com with ESMTPSA id u18sm13183780ilj.20.2021.05.25.00.39.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 May 2021 00:39:27 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: [PATCH] Fix pgrep/pkill -f completion From: dana In-Reply-To: Date: Tue, 25 May 2021 02:42:00 -0500 Cc: Zsh hackers list Content-Transfer-Encoding: quoted-printable Message-Id: <2FA8FD65-1BE2-4E22-BD0A-ABA922D814BE@dana.is> References: To: Marlon Richert X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Seq: 48920 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 21 May 2021, at 07:59, Marlon Richert = wrote: > Old completion produced false positives & took too much screen space. There are a few issues with this: 1. procps-ng needs -a or -la instead of -lf to get the expected output. = I can't recall off the top of my head whether *BSD and Solaris -lf = output will work, but for now i'll assume so 2. The pgrep command needs -- in case the pattern starts with - 3. The pattern needs quoted again, since it's being passed to eval 4. There's an error in the :-escaping 5. On my macOS machine there's now a delay of about 5 seconds before the = full possibilities are shown, whereas the previous method was pretty much instantaneous. I guess this is something to do with the large size of = the full output on my Mac (65'000+ chars due to the paths i mention = below), since it's much faster if i include a $PREFIX. But the parameter = expansions shouldn't be that slow with just 64K of text, so maybe it's an = inefficiency in _describe? I didn't look into it much 6. It's not a problem with the change *per se*, but the default max-matches-width can make the menu really irritating when you have = several PIDs corresponding to the same command; they push the actual command = line off the edge of the screen, and since on macOS you have a million = things in the list that begin with long absolute paths, you just get a whole = screen full of... 1008 = /System/Library/PrivateFrameworks/Pa 1077 = /System/Library/PrivateFrameworks/Us 1099 = /System/Library/PrivateFrameworks/IM 1204 = /System/Library/PrivateFrameworks/Ke ... which is not very helpful at a glance. idk if anything should even be done about that, but i thought i'd = mention it at least Attached fixes the first four issues (Not sure i understand the weird indentation rules for continuation in completion functions =E2=80=94 i never followed them before but i = remember someone mentioned them recently =E2=80=94 lmk if i messed it up) PS: This change didn't introduce it, but the $ispat thing doesn't make = sense to me. It implies that -x is a literal match, which isn't the case; it's = a pattern match either way. I've included a second patch that hopefully = makes that distinction more accurate/meaningful. (Use -C2 if applying out of = order) dana diff --git a/Completion/Unix/Command/_pgrep = b/Completion/Unix/Command/_pgrep index e10f42f53..bde681dd2 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -170,10 +170,13 @@ case $state in ispat=3D"" fi if (( ${+opt_args[-f]} )); then + local -a opts=3D( -lf ) + [[ $OSTYPE =3D=3D linux* ]] && opts=3D( -a ) local -a matches=3D( ${(f)"$( - _call_program process-args pgrep -lf = ${${:-$PREFIX$SUFFIX}:-.\*} + _call_program process-args pgrep ${(@q)opts} -- \ + ${(q)${${:-$PREFIX$SUFFIX}:-.\*}} )"} ) - local -a displ=3D( "${${matches[@]//':'/'\:'}[@]/ /:}" ) + local -a displ=3D( "${${matches[@]//:/\:}[@]/ /:}" ) matches=3D( "${matches[@]##<-> }" ) =20 local desc=3D$ispat'process command line' diff --git a/Completion/Unix/Command/_pgrep = b/Completion/Unix/Command/_pgrep index bde681dd2..38b1aebd8 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -167,7 +167,7 @@ case $state in (pname) local ispat=3D"pattern matching " if (( ${+opt_args[-x]} )); then - ispat=3D"" + ispat+=3D"full " fi if (( ${+opt_args[-f]} )); then local -a opts=3D( -lf )