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

Re: Strange behavior with "for i in .."



On 23 September 2011 12:29, Volodya Khomchak <kolombo.inc@xxxxxxxxx> wrote:
> Hi,
>
> I faced with strange behavior with "for i in ..".
> So the problem is next:
>  # for i in /etc/profile.d/*.sh;do echo $i;done
>  # zsh: bad math expression: operand expected at `/etc/profi...'
> But if I change "i" to "file" it would work:
>  # for file in /etc/profile.d/*.sh;do echo $file;done
>  # /etc/profile.d/1.sh
>  # /etc/profile.d/2.sh
>
> zsh --version
> zsh 4.3.10 (x86_64)
>
> So what is going on here ?

At some point you've done 'integer i', so when you assign to i it will
be evaluated as a math expression. Try "echo ${(t)i}". "unset i"
before the loop should fix it.

-- 
Mikael Magnusson



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