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

Re: Zsh noob: word-splitting headache



On Tue, 4 Jan 2005 kynn@xxxxxxxxx wrote:

>   for i in `foo`
>     do something with $i
>   done
> 
> fails, because i holds individual words instead of whole lines.

Use a different construct.

   foo | while read i; do something with $i; done

This works nicely in zsh because zsh executes the right-hand-side of 
pipelines in the current shell when it can.  It might not work as well in 
other shells, but other shells don't have Clint's suggested ${(f)...} 
expansion either.



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