Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Most Recent File



On Sat, Oct 23, 2021 at 12:08 PM Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx> 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.




Messages sorted by: Reverse Date, Date, Thread, Author