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

Re: read -sq



On Sun, Feb 21, 2021 at 1:58 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> ...
> >    : ${(P)${1:-REPLY}::=''}
>
> this is fundamental syntax that I still don't understand.

Replace it everywhere with

typeset -g ${1:-REPLY}=whatever

if that makes it more readable.

You know what ${1:-REPLY} does, I presume.

${thing::=value} assigns value to $thing and substitutes value

${(P)thing} uses the value of thing as a variable name and retrieves
that variable

So ${(P)${1:-REPLY}::=''} is:
-- get $1 or if it isn't set use REPLY
-- retrieve the variable whose name that is
-- assign the empty string to that variable

Then the ":" command is merely to throw away the substituted result of ${...}.




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