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,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24737 invoked from network); 23 Oct 2021 20:58:26 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Oct 2021 20:58:26 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635022706; b=Mzx6FTzFEbW8X7CR0pO9gNlvdELDG28b6L7v04iwTspONQQ5nsUqmadUC/mAFC+nOsZ8Z4nfNw jeDdTZ4aid4MR0GMPVjEqxDUj6fKst6cQ1K32wX+3IPMkcGFJTGty0Z1UR3aIFgx5VrRA/JeNF Mw2IVGs7MUOT69SCb2NPToguGfRk5Bmp365YMGJFM5FdNexVuYq2+l8oDKpgfsLJ2l0KrYgp5u Yv20ROnKAEq2cbXABVEropXCfWS/RuyZVy5es73TX416w4x6Ffy+3GFf1XdDM2+/ewuQhncugQ VuNx5IiT6lfvZg3EkrwKyf8FFf2MAw2DvpEj70oYLbntTw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-io1-f49.google.com) smtp.remote-ip=209.85.166.49; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1635022706; bh=7TdwHGUV1VO69RB2pto0KvMJKgu+LYPeA+yGhAqwSMM=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=XGvSM2SZQ+detFaE82Rqv50spIJKjaywGoCaNU3ye/Bl640cfY7PaczzeEv1RSSfByXIMDxecC PJyxTg99bxO53OEL5qLPVFMKCXukUap6TecDM4FtyCO1L2PwKQgeHbqfCJVWFlLDKJOn/tQ7LM qi8nmmEpUDn2YWLX9z8EWg3ndt48Zp/qwxRu/sWzbKLEPLJIHF4LKdEy0o838iSnlOUJ6vz0uZ yYpAmRrfmd9c2bRIjpxSrNjtERDd0epF24ygQgGjUMk8DTowA4HkgAh0j0q33EGIbZmbqPZPbs S7ULRwqJ5XPGuhDY8zBhuN0rWZFB5GG2RSeM7D8VHbyg0Q==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HiBLGl17cvrLqJobQa0MBQEcqwJHFZ+MHiH6yhrlUPM=; b=cP6RZJKDiSZZtRJjUs1Fbp7B9f I15kJxe6BYrZKIAz9BkdMZHWqlWOj1h8unXbv7yQgQq6Zl//lOeeEcNnUzxXyvgRo9QJicSjFL1jQ YP+nkgJR65gzhABMd8lx1Fa0X/pkaq1LFy2k9WcqlIhA29gWN6ugT8TL2UnWWZ/ddt7O2YXtECNUo dpauunpp+H9Va9gBtyYP36PIaqIDnaoHJtkVgdLi2NLR1G7PWAJsLQvqA728Ogrwu9UKkCbU6q4LD yaDGAO0ox1u2gHsrXSAahSV/23eo2K9uZHX+eXJwMnBGyfn5pamd4DepLC75vEh/Bl8As4Yz8HMUm MVxNT/sA==; Received: from authenticated user by zero.zsh.org with local id 1meO5y-000HQH-BL; Sat, 23 Oct 2021 20:58:26 +0000 Authentication-Results: zsh.org; iprev=pass (mail-io1-f49.google.com) smtp.remote-ip=209.85.166.49; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-io1-f49.google.com ([209.85.166.49]:42872) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1meO59-000Ghm-Vg; Sat, 23 Oct 2021 20:57:37 +0000 Received: by mail-io1-f49.google.com with SMTP id z69so10133308iof.9 for ; Sat, 23 Oct 2021 13:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HiBLGl17cvrLqJobQa0MBQEcqwJHFZ+MHiH6yhrlUPM=; b=eoNrjk1Lv34mEO/T4MCg88qYUru+TKTYwDzpv2fHIoc4NpjABdXGWa1fDrPyhp5Rnx cU9cTBs9or990rE7dA0mFbNp+sNrGCoy10vRrXainiietJPVIo05GxpAlqXnn6f6Bx+h VAwUDbwKr61zIM0bmff+exdFlSxPuzPu3NMUubFHjructq7ezXmc1kPbvCeevvRFmS7+ Fx6P2ZhM6p+9y//X/A2AH+oxB232VjOoyJcspLcDUvIDAUIqZHp9DtaDrsWV09P+ePsD k21ldLmH2jjPIXhbLPyANQ99jlse3G9FlLzZ4Q5K4DFm8XyC3JZ5dT8nrajkJAKJsl6Q VJgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HiBLGl17cvrLqJobQa0MBQEcqwJHFZ+MHiH6yhrlUPM=; b=aNkmTgoqv0HpX2Bup5Hgw/y36NzRYkaUJ3N9RnhLl6ZQQMQMKg8SIWuxflQzUTYPzh 2293XpxYBgmn9k3qd52pMW39PyDxeBms8fsYn13zBGU94EjHYYyWTOZdW70pm6lCXjmv 74uWt1nIB469NPC5XUEpx01YpQPVAAiX5YMUobERMhcJ3TSzIMj1O9c+ThVaGMhQlCCI rRkB/+vo6boQFTd8vAhq2znEjgjaLqISWmvm9rMPNlqh9aysQJ9u0deWb+Vx4vk6mowh cYTssHLwvCUDVa01UvHD02CEPcKYKxjLrEfc8ZMUNXdglWCNjTK8d/xoG9+IrjphtAkc YWbA== X-Gm-Message-State: AOAM5301gmYLN1yjpENWHbjjKmYTL43szuIuV2y8Hcd/ZWvRDXukyHay r8pJUxaIs2T8NorgCxP3fW162gk6BgxIUMtDiaw= X-Google-Smtp-Source: ABdhPJzIcLdPNquI/JxSjOi7T/3hqoJh91gX5jrUKJl4D/qmNrFGGA5y+m/S9MiojKjl/J1JYf0+IXC/esnb9zB4axs= X-Received: by 2002:a02:8643:: with SMTP id e61mr4911586jai.97.1635022654717; Sat, 23 Oct 2021 13:57:34 -0700 (PDT) MIME-Version: 1.0 References: <20211023164338.GA6763@gmx.de> <095002061dc32afdfb1dcfe51e1171e23e62375d.camel@ntlworld.com> <20211023172445.GA8911@gmx.de> <0b757d10f1a2374d5a84199fbed71314e16fea63.camel@ntlworld.com> In-Reply-To: From: Pier Paolo Grassi Date: Sat, 23 Oct 2021 22:56:59 +0200 Message-ID: Subject: Re: Most Recent File To: Vin Shelton Cc: Bart Schaefer , Peter Stephenson , Zsh-Users List Content-Type: multipart/alternative; boundary="00000000000088c2a505cf0b607c" X-Seq: 27276 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: --00000000000088c2a505cf0b607c Content-Type: text/plain; charset="UTF-8" I think to use it that way you should remove the quoting: print -lr -- ${(@)f} and use it like this: ls "${(f)$recent 3)}" to have the output of recent to be split at newlines and treated as separate arguments would be nice not to have to write all this boilerplate though (I use global aliases for that) hope someone will show a better/simpler way Pier Paolo Grassi Il giorno sab 23 ott 2021 alle ore 22:44 Vin Shelton < acs@alumni.princeton.edu> ha scritto: > Thanks, (I had tried the (q) and the extra assignment after pws suggested > it) but no luck: > > zsh -f > > nuc2% function recent { > function> local dir= > if [[ $# -gt 2 ]]; then > if [[ ! -d "$3" ]]; then > print -u2 "$0: directory \"$3\" does not exist." > return 1 > fi > [[ $3 != '.' ]] && dir="$3"/ > fi > > local f=( ${dir}${~2:-*}(-om[1,${1:-1}]) ) > print -lr -- ${(@q-)f} > } > nuc2% recent 3 > zsh > 'Any Given Sunday.mkv' > TheEnglishPatient.mkv > nuc2% \ls -ld $(recent 3) > ls: cannot access "'Any": No such file or directory > ls: cannot access 'Given': No such file or directory > ls: cannot access "Sunday.mkv'": No such file or directory > -rw-r--r-- 1 acs acs 727146010 Oct 22 15:52 TheEnglishPatient.mkv > drwxr-xr-x 3 acs acs 3488 Oct 23 12:20 zsh > > > What am I doing wrong? Does quoting not work correctly in captured output? > > I appreciate knowing that printf is builtin; thanks. Sorry I missed that. > > - Vin > > > On Sat, Oct 23, 2021 at 3:26 PM Bart Schaefer > wrote: > >> On Sat, Oct 23, 2021 at 12:08 PM Vin Shelton >> wrote: >> > >> > print -l -- ${dir}${~2:-*}(-om[1,${1:-1}]) >> >> You're still missing any of the (q) options on those expansions. >> >> The easiest thing to do here is something like >> >> local recent=( ${dir}${~2:-*}(-om[1,${1:-1}]) ) >> print -lr -- ${(@q-)recent} >> >> It's important to add the quoting after any globbing but before you >> print the result. >> >> > Do I really have to use an external command (like `printf') to make >> this work? >> >> printf is a zsh builtin, for some years now. But as long as you add >> quoting and do not use echo, you should be OK. >> > --00000000000088c2a505cf0b607c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think to use it that way you should remove the quoting:<= div>
pr= int -lr -- ${(@)f}

and use it like this:

ls "${(f)$recent 3)}"

to have=C2= =A0the output of recent to be split at newlines=C2=A0and treated as separat= e arguments
would be nice not to have to write all this boilerpla= te though (I use global aliases for that)
hope someone will show = a better/simpler way

<= div dir=3D"ltr">
Pier Paolo Grassi


Il giorno sab 23 ott 2021 a= lle ore 22:44 Vin Shelton <a= cs@alumni.princeton.edu> ha scritto:
Than= ks, (I had tried the (q) and the extra assignment after pws suggested it) b= ut no luck:

zsh -f
nuc2% function recent {
function> local dir=3D
<= /span>if [[ $# -gt 2 = ]]; then
= =C2=A0 if [[ ! -d "$3" ]]; then
=C2=A0 =C2=A0 print -u2 "$0: directory = \"$3\" does not exist."
=C2=A0 =C2=A0 return 1
=C2=A0 fi
=C2=A0 [[ $3 !=3D '.' ]] &am= p;& dir=3D"$3"/
fi

local f=3D( ${dir}${~2:-*}(-om[1,${1:-1}]) )
print= -lr -- ${(@q-)f}
}
nuc2% recent 3=
zsh
'Any Given Sunday.mkv'
=
TheEnglishPatient.mkv
nuc2% \ls -ld $(recent 3)
ls: cannot access "'Any": No such file or dire= ctory
ls: cannot access 'Given': No such file or d= irectory
ls: cannot access "Sunday.mkv'": No= such file or directory
-rw-r--r-- 1 acs acs 727146010 Oct= 22 15:52 =C2=A0TheEnglishPatient.mkv
drwxr-xr-x 3 acs acs= =C2=A0 =C2=A0 =C2=A03488 Oct 23 12:20 =C2=A0zsh
<= div class=3D"gmail_default" style=3D"font-family:"times new roman"= ;,serif;font-size:large">
What am I doin= g wrong?=C2=A0 Does quoting not work correctly in captured output?

I appreciate kno= wing that printf is builtin; thanks.=C2=A0 Sorry I missed that.

=C2=A0- Vin


On Sat, Oct 23, 2021 at 3:26 PM Bart Scha= efer <sch= aefer@brasslantern.com> wrote:
On Sat, Oct 23, 2021 at 12:08 PM Vin Shelton <acs@alumni.prince= ton.edu> wrote:
>
> print -l -- ${dir}${~2:-*}(-om[1,${1:-1}])

You're still missing any of the (q) options on those expansions.

The easiest thing to do here is something like

local recent=3D( ${dir}${~2:-*}(-om[1,${1:-1}]) )
print -lr -- ${(@q-)recent}

It's important to add the quoting after any globbing but before you
print the result.

> Do I really have to use an external command (like `printf') to mak= e this work?

printf is a zsh builtin, for some years now.=C2=A0 But as long as you add quoting and do not use echo, you should be OK.
--00000000000088c2a505cf0b607c--