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

Re: Most Recent File



On Sun, Oct 24, 2021 at 3:48 AM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> On Sat, Oct 23, 2021 at 07:32:09PM -0500, Paul wrote:
> >       recent(){
> >               # Use $reply if no parameter name given
> >               typeset -ga "${2:=reply}"
> >               set -A "$2" *(om[1,$1])
> >       }
>
> >       recent 3 files; ls -ld $files
>                                ^^^^^^
>
>   ls -ld -- "${files[@]}"

The "--" is a good addition but the other suggested changes only make
a difference if KSH_ARRAYS or SH_WORD_SPLIT is set. Neither is set in
native mode and few zsh users set them.

It's one of the nice things about zsh that you can use the shorter
$foo and $#foo instead of "${foo[@]}" and ${#foo[@]}. I wish there was
an option to disable null elision with a corresponding expansion flag
to turn it on similar to no_sh_word_split and ${(=)name}

Roman.




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