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

Bug? in 'integer' behaviour



Hi.  I'm not subscribed, so please email me if there's anything else
you want to know (but I don't think anything is peculiar to my setup in
this one).  I'm using version 3.1.4 on Linux/x86.

In the distribution is Functions/randline which purports to show a
random line from a file.  The problem seems to be caused by a variable
declared integer not stripping off leading whitespace when assigned to.

randline:
 # get a random line from a file
 integer z=$(wc -l <"$1")
 sed -n $[RANDOM%z+1]p "$1"

This produces a divide by zero error, as 'z' is always zero.  Removing
the 'integer' keyword solves this, as does wrapping the RHS of the
assignment in $[...].

Is this unintuitively correct (features, gotta love 'em) or a bug?

Thanks.
-- 
--> Phil Pennock ; GAT d- s+:+ a22 C++(++++) UL++++/I+++/S+++/H+ P++@ L+++
E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++ DI+ D+
G+ e+ h* !r y?



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