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

Re: for x in * evaluates filenames as arithmetic expressions?



Einar Huginson wrote:
> When executed in a directory containing files with names such as
> 
> 	2004-10-22.txt
> 	2004-10-29.txt
> 	...
> 
> a ZSH command of
> 
> 	for x in *
> 	do
> 		echo $x
> 	done
> 
> fails with
> 
> 	zsh: bad math expression: operator expected at `txt'

This means that the shell thinks x is an integer variable.  Check this
with

  print ${(t)x}

Use

  typeset +i x

to revert it to a scalar.  On the command line, simply "unset x" would
be good enough.

Obviously, you'll have to check what you've been doing to see why
it would have become an integer.  It certainly wouldn't do that because
of a "for" loop.  If you've still got the old command list associated
with x we can probably work it out.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, 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.

**********************************************************************



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