From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4128 invoked from network); 5 Oct 1998 09:53:25 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 5 Oct 1998 09:53:25 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id FAA15111; Mon, 5 Oct 1998 05:43:04 -0400 (EDT) Resent-Date: Mon, 5 Oct 1998 05:43:04 -0400 (EDT) Message-Id: <9810050933.AA29858@ibmth.df.unipi.it> To: zsh-workers@math.gatech.edu Cc: Phil Pennock Subject: Re: Bug? in 'integer' behaviour In-Reply-To: ""Bart Schaefer""'s message of "Mon, 05 Oct 1998 02:20:13 DFT." <981005022013.ZM1469@candle.brasslantern.com> Date: Mon, 05 Oct 1998 11:33:55 +0200 From: Peter Stephenson Resent-Message-ID: <"TsdHx1.0.2i3.dI96s"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4410 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu `integer z=$(wc -l <"$1")' gives $z = 0: Bart wrote: > } I think it's the trailing characters after the number which are causing > } the problem. From wc you get something like > } 128 .zshrc > > No, that can't be right. Note that input is being redirected to wc, so > it doesn't produce the trailing file name. You're quite right, things like "<" aren't so obvious first thing on Monday morning. I looked a little further and here's what's happening: % showargs() { print -l $*; } % showargs z=$(wc -l <~/.zshrc) z= 168 Replace `showargs' by integer and you'll see that the first argument is z=, so that z gets 0, then the $(...) substitution splits words on the initial spaces, and the second argument is 168. I haven't looked to see what zsh thinks it's doing with `integer 168', but the word-splitting here does seem to be standard Bourne/Korn shell behaviour. So the real workaround is integer "z=$(wc -l <$1)" or integer z z=$(wc -l <"$1") It's a little confusing that the argument to an `integer' isn't handled the same as a straight assignment, but I don't see a way around. -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Gruppo Teorico, Dipartimento di Fisica Piazza Torricelli 2, 56100 Pisa, Italy