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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23346 invoked from network); 23 Oct 2021 20:44:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Oct 2021 20:44:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1635021876; b=Eog3Mi1XNTHmy3mhsVHTTw7gG8rjSZQ3bLUK433J6FIjAMx3dnSp/6oiuJbIhL1TWhtnHExNKQ PODss3R4dfZOyN9I43hWKEJz2Ei9c04L50fcu9Qls6IiMxNRd/2i49bAbFbu5hkatoApdqkeIt RmwMC8DW0WGkhwnsMchAAcCBh725YsByo1DYRWvxlZvyMQT6ESixc6/I+DphYLUr8KARdw8e8w KotIVp6XMyBBcHYrXg/j9coyAXZUS9fak/ZnEOy+TnUGTwJIU5+JrXVtCduTgbZCE1z+dqmfuQ ASvz+Y1HNTVGu3lGOcPhMnHi+TGIrInzEOlGk7lZGO2+DQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f44.google.com) smtp.remote-ip=209.85.208.44; dmarc=none header.from=alumni.princeton.edu; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1635021876; bh=LR1OgYn2rfgTPqi0KaqSI7+KCD4h2J1mYhMaxm//28U=; 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; b=A9gTmpeQaH/3vU+B8CNvpXgbv4kg5RgtPzbW7fFxiypY9I8NxEH4ZXrizrNkIMwfDjXZx792PY QJ885kcatnybz3lXEYu3smCbU8EN8tlsngeWvligDuZxwXSy3k6ggEWUGxHx9PAh4JhvDVFHsC Zv0X9WcIiwXlVznReoWwkfHMn5g/3v/EwYWZfTyf0QG0W5ymTNWoNV4aRjuOtUm0Giiw/8Poxk kc7T8u+JhzaISrqeV/rX/Jq9AISop/BtBnfi51Mcf805An9QMR+RNbd/OmVCBIZSPR6+TfiRUR VuK6lgnYqW9+HfPgczSTckAUNvMxe2cFbxNwbhYmPPqs+g==; 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=NCW4JDgniyKGnaixsPkQgT56KcZJWsxtWVUtwMX2/ns=; b=ROqRFWXAo0ajAm4a6hR5jZ58Qr f8A/ldMAXRQRrRN88++BLWUVvXdIVuif009Dw+Z66xm1O5OMhF5nw5UxqdV0OHKxVP0HG8EamjZ0o /EJ/EhemyAsEoN0FZX8T/mv4YQRFrfPYipb9nEQpTLMFE3cpi08mzF25UPUcq4iMgrWVbV1u9dzq8 a9fA3n1xqn5ewpwfPCB0E9PO6qClQNQ8asV2QH2E1KxbaT592pZNM6Nku4lxu2LA9dA2WAeRE93bd VtvEgSBUNWQge2U53/2aX5X0qSzp/w6FJmoDc2yOxJ8EnvJ9R7b2RcxMoMDIMcZV8ubUqImqEta5/ 7ptmqI7A==; Received: from authenticated user by zero.zsh.org with local id 1meNsZ-000FiU-Ox; Sat, 23 Oct 2021 20:44:35 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f44.google.com) smtp.remote-ip=209.85.208.44; dmarc=none header.from=alumni.princeton.edu; arc=none Received: from mail-ed1-f44.google.com ([209.85.208.44]:33382) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1meNry-000F1G-3O; Sat, 23 Oct 2021 20:43:58 +0000 Received: by mail-ed1-f44.google.com with SMTP id e19so619024edy.0 for ; Sat, 23 Oct 2021 13:43:58 -0700 (PDT) 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=NCW4JDgniyKGnaixsPkQgT56KcZJWsxtWVUtwMX2/ns=; b=vnYMhVk6AZCabQJ8WcfE+s6aWOLthy6aeE4SGolgRy0Ejly1oyd6fHu4SbdX/t/wbM xoTOJw5CmdgqffjSSlekKNE+eSAeayvsKZnTCypQXL9kfNOK05AFCWqamKPxUmD86qO2 ykmPUqrj5ZR5StfOn2FdUKhWWL5vtk6TS3itGsJQRn/yF6atWasfd7ziqadcixDwXydC 1dzRaV0zf4nvlcoZ+YccRfEabY9BMtkjdB9chz4wjwMgQobwJ4e1o0i6ALxG5GWDBSZj q0bcwEj4/V9mVd2qbybb1f7ieUH5CZz8Gp4694fcHQM1mfdUvVsHSiq8xhJh6B4GjO1+ BEtg== X-Gm-Message-State: AOAM531r8NXSN+VzhnvsTWYokmgtSAt4OgUQ0pTjxTilnKahwz3SHx6r r0wVwJW48yYIdUvnXT+0AGvQyfxnrHarUqiNgw1nLZagXsI= X-Google-Smtp-Source: ABdhPJxkDI4nPOkRetPMDUB5osXGI+E1e37Bfsm0MuGBGJQWzq66QcgH2rssgqGzGGge780c+u91YDATuXLBGM02wg8= X-Received: by 2002:a17:907:1c0d:: with SMTP id nc13mr5068834ejc.390.1635021837590; Sat, 23 Oct 2021 13:43:57 -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: Vin Shelton Date: Sat, 23 Oct 2021 16:43:21 -0400 Message-ID: Subject: Re: Most Recent File To: Bart Schaefer Cc: Peter Stephenson , Zsh-Users List Content-Type: multipart/alternative; boundary="000000000000d46ac005cf0b2f8a" X-Seq: 27275 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: --000000000000d46ac005cf0b2f8a Content-Type: text/plain; charset="UTF-8" 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. > --000000000000d46ac005cf0b2f8a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks, (I had tried the (q) and the extra a= ssignment after pws suggested it) but no luck:

zsh -f
<= blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px">nuc2% function recent {
function> local = dir=3D
if [= [ $# -gt 2 ]]; then
=C2=A0 if [[ ! -d "$3" ]]; then
=C2=A0 =C2=A0 print -u2 "$0: d= irectory \"$3\" does not exist."
=C2=A0 =C2=A0 return 1
=C2=A0 fi
=C2=A0 [[ $3 !=3D '.= 9; ]] && dir=3D"$3"/
fi

<= /font>
local f=3D( ${dir}${~2:-*}(-om[1,${1:-1}]) )
<= div class=3D"gmail_default" style=3D"font-size:large">print -lr -- ${(@q-)f}
}
nuc2% rece= nt 3
zsh
'Any Given Sunday.mkv'
TheEnglishPatient.mkv
nuc2% \ls -ld $(rece= nt 3)
ls: cannot access "'Any": No such file= or directory
ls: cannot access 'Given': No such f= ile or directory
ls: cannot access "Sunday.mkv'&q= uot;: No such file or directory
-rw-r--r-- 1 acs acs 72714= 6010 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

What am I doing wrong?=C2=A0 D= oes quoting not work correctly in captured output?

<= /div>
I appreciate knowing 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 <schaefer@brasslantern= .com> wrote:
On Sat, Oct 23, 2021 at 12:08 PM Vin Shelton <acs@alumni.princeton.edu> wr= ote:
>
> 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.
--000000000000d46ac005cf0b2f8a--