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

Re: compaudit:74: _i_addfiles: assignment to invalid subscript range



Peter Stephenson wrote:
> % test=()
> % for i in {1..$#test}; do print $i; done
> 1
> 0
> 
> It's looping over a non-existent and a not-even-valid entry for an empty
> array, which is not very helpful.  That number is then being used as
> a subscript for the empty array.  I'm not actually sure the syntax
> {1..0} should be doing that, I don't think we've ever defined what it
> does.

Ah, I'm an idiot.

       If the  numbers  are  in  decreasing
       order the resulting sequence will also be in decreasing order.

So the brace expansion is doing exactly what it's been asked to do.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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