From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 9ADF124044 for ; Sat, 20 Apr 2024 16:25:32 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1713623132; b=Q2b2dUwqInvwFNGmcygknFBx53sKFE19LkLe4RXxETYSXqu1CqonehV/ZKJtz0T6Ghd9GZtA8y qD5g92PbaZ8FLjb1USvTxrv9mxaJ0ACPbg0myBTCmwqXNCXxmx6o9MzSFVzAANTUTorJNs21Co xHMJi/1yV10tVrDZ18+de1bOWg6vVplBgSHUKgY1uN7E0f6Eh8hUi/G8ng/DIWkl9/ZoNsX9HW senm0E5h0qq3jk7p9cMXfIYNLCZ6QX0no+N2wg4jk5fUMa4GojAQ/XAgeT/zIQCEwwJHRdGETA X1IKF1fieK/8lzcXN834fZ2IIoTzuCDigryiccKTopvifA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1713623132; bh=LQWEjowtxwAmZAbEEbBUKQeySQI4iPDYepUcNyyEWGI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=d8G1+0QmHfaAr7y/ZXbkIcbcIDuZkrWHAVQyZkEUkA4Y2/ub9ZWba/bZhOa22S4f7lWoYZc4zD OrwtuXu8MjYNwQyjrxlY+NZ9BrwYyJ7zX16jriTqpzLtCDrBys+PabMHGCnQFx34XqTxTQhyla kwjpfhhWJGiKQaGLnt41ki/ugkFnmVYd0+0Lbwxq0um4I+Sr1N2U53A2qc0ai5aGYhniPeIB1F 6kgJtESuJOEGFOJvQ+jPTQkudncMLTQARhPKbv46rlLxHNBHp0dKv7uczxTurMqLM+nGYy9QdF l2i+7chi74yJz0MuoziCHM4GoNPalMoxoFM7H4/pwR7JEg==; 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:In-reply-to:From:References:To: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=CVNtYeJZHmIUrXIlTkImOFUg/qq6C50/90KNRWTdyDk=; b=IPiLVQLe4RJY6NZPzLUH3ib88T Wwd7w/u1qwed6bh30w/WnaPF9dqYM5bgfLrjQehOOoZrAz07kVn2AYFC8/d5+++eOAVh/IfTrLwis b2Tayin0xjgsw/cgJHZk5uZYwsRhFFoKUxRj9xHgL0V9S5xR3E8KijXekRkwfDmspWrTAhBb3tFDH RYXidIrUFpEXF8KIibUnjH787OrVJyWtNQ35vTEMuH+C3eeViuOckeMeyF3dgJRH9YAqgjWBPKVxu Kc0duuEIXiEN/QiKQ3d6ZXYpbnVqf6hnNJPP7vQOt5g9G1uD2rsM5bS0T165WmTcPFDlXjvTPpQiA GgvRcdmA==; Received: by zero.zsh.org with local id 1ryBel-00004V-Tm; Sat, 20 Apr 2024 14:25:31 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:42221) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ryBd5-000P8x-B6; Sat, 20 Apr 2024 14:23:48 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta04.eastlink.ca ([24.224.136.10]) with ESMTPS id <0SC8222F3VZAECF0@mta04.eastlink.ca> for zsh-users@zsh.org; Sat, 20 Apr 2024 11:23:45 -0300 (ADT) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp02.eastlink.ca ([71.7.199.167]) with ESMTPSA id yBd3r1Sjj5TsryBd3rHz6y (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Sat, 20 Apr 2024 11:23:45 -0300 X-Authority-Analysis: v=2.4 cv=deIj3mXe c=1 sm=1 tr=0 ts=6623cff1 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=RuYc8_oi6fQmoacVSR0A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=a-ZT7DKlmgLUmRLiwjsA:9 a=LcEETXEugOIR8Mwk:21 a=_W_S_7VecoQA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudekgedgjeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------nWQ0M4lVCSu8dH5lgN8GBlGd" Message-id: <3d15311d-b5fa-4a55-a17e-e61fcdded7d0@eastlink.ca> Date: Sat, 20 Apr 2024 07:23:44 -0700 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: optimal expansions? To: zsh-users@zsh.org References: <53fab6be-26d7-4de5-844f-ffc295d9a494@eastlink.ca> Content-language: en-US From: Ray Andrews In-reply-to: X-Seq: 29843 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: This is a multi-part message in MIME format. --------------nWQ0M4lVCSu8dH5lgN8GBlGd Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-04-20 00:42, Roman Perepelitsa wrote: Hafta start using lines like this all the time.  You guys never start a function without one of these 'emulate' instructions -- make sure that the func has the environment it needs. > emulate zsh -o no_unset -o pipe_fail -o err_exit > () { > local last_pkg pkg file So you break it into words automatically here, and any spaced filenames end up in 'file' anyway! > apt-file search "$1" | while read -r pkg file; do > if [[ $pkg != $last_pkg ]]; then > [[ -n $last_pkg ]] && print > last_pkg=$pkg ... this line is Basque to me.  It works but I have no idea how. Anyway that's for me to research.  It baffles me that there's color codes in there. > print -P "%B%2F${pkg//\%/%%}%f%b" > fi Seems we want '-r' most of the time.  And the '--' should always be there.  Now that I know not to use newlines for splitting.  And of course that obviates most of my '(@f)'s too. > print -r -- $file > done > } "$@" > > This implementation fixes a couple of bugs in addition to those > mentioned by Lawrence: it gets rid of the empty line at start of the > output, and leaves whitespace in file names unchanged. To pick nits I want the leading empty line.  But I'm betting your code will be faster.  I'll keep Lawrence's edits until such times as I understand that 'print -P' tho. --------------nWQ0M4lVCSu8dH5lgN8GBlGd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

On 2024-04-20 00:42, Roman Perepelitsa wrote:

Hafta start using lines like this all the time.  You guys never start a function without one of these 'emulate' instructions -- make sure that the func has the environment it needs.
emulate zsh -o no_unset -o pipe_fail -o err_exit
    () {
      local last_pkg pkg file
So you break it into words automatically here, and any spaced filenames end up in 'file' anyway! 
      apt-file search "$1" | while read -r pkg file; do
        if [[ $pkg != $last_pkg ]]; then
          [[ -n $last_pkg ]] && print
          last_pkg=$pkg
... this line is Basque to me.  It works but I have no idea how.  Anyway that's for me to research.  It baffles me that there's color codes in there.
          print -P "%B%2F${pkg//\%/%%}%f%b"
        fi
Seems we want '-r' most of the time.  And the '--' should always be there.  Now that I know not to use newlines for splitting.  And of course that obviates most of my '(@f)'s too.
        print -r -- $file
      done
    } "$@"

This implementation fixes a couple of bugs in addition to those
mentioned by Lawrence: it gets rid of the empty line at start of the
output, and leaves whitespace in file names unchanged.
To pick nits I want the leading empty line.  But I'm betting your code will be faster.  I'll keep Lawrence's edits until such times as I understand that 'print -P' tho. 



--------------nWQ0M4lVCSu8dH5lgN8GBlGd--