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

Re: associative array questions



On Tue, Dec 13, 2022 at 9:01 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2022-12-13 08:22, Roman Perepelitsa wrote:
>
> eval 'list=( "${(@M)list:#(#i)*$SEARCHBUF*}" )'     # filter the array.
>
> This eval will expand things that you don't want expanded. Use `set -A $list` instead.
>
> Roman.
>
> I think I'm missing something Roman,  can't make it work.  Tried a few variations:
>
> set -A $list=( "${(@M)list:#(#i)*$SEARCHBUF*}" )
> set -A $list=( "${(@M)${(P)list}#(#i)*$SEARCHBUF*}" )
> set -A $list=( "${(@M)${(P)1}#(#i)*$SEARCHBUF*}" )

`set` is a builtin (not a reserved word), so you use it like a normal
command. Your first email in this thread used it correctly. You can
also refer to `man zshbuiltins` for documentation.

> BTW is it possible to redirect the error messages and especially 'set -x' output?  All this is with zcurses active so the messages are hidden or chopped up.

Unlike bash, zsh cannot send xtrace output anywhere but to stderr. If
you redirect stderr, xtrace output will be redirected too.

Roman.




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