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

Re: Can this be done with an array parameter?



DervishD wrote:
>     And my original question: can the array be assigned one line of
> the file per slot without the loop?

array=(${(f)"$(<filename)"})

$(<filename)
  Substitute the file.
"..."
  The substitution is performed as a single command line argument.
${(f)...}
  Split the result into one element per line (a pseudo-parameter-substitution;
  they allow command substitutions, too).  (Sometimes you see an @ next to
  the f to tell it the result is an array; this is harmless but unnecessary
  in this case.)

There are lots of examples like this in the completion code, except most
are about fifty times more complicated.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



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