Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Can this be done with an array parameter?
- X-seq: zsh-users 7062
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx (Zsh users list)
- Subject: Re: Can this be done with an array parameter?
- Date: Thu, 19 Feb 2004 17:00:54 +0000
- In-reply-to: "DervishD"'s message of "Thu, 19 Feb 2004 17:46:31 +0100." <20040219164631.GB2804@DervishD>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
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