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

Re: possible bug in zsh concerning a for loop



On 2022-03-18 17:45:22 +0900, Jun T wrote:
> You can get this by:
> 
> [1] use array (instead of scalar parameter items)
> 
> a=( item1 item2 item3 )
> for i in $a; do ... done
> 
> [2] use ${=items}
> 
> for i in ${=items}; do ... done
> 
> [3] set SH_WORD_SPLIT option
> 
> setopt SH_WORD_SPLIT
> for i in $items; do ... done
> 
> I prefer [1], but it is up to you which method you use.

[1] has the advantage that it supports arguments containing spaces.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




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