From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@math.gatech.edu
Cc: Phil Pennock <phil@athenaeum.demon.co.uk>
Subject: Re: Bug? in 'integer' behaviour
Date: Mon, 05 Oct 1998 11:33:55 +0200 [thread overview]
Message-ID: <9810050933.AA29858@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Mon, 05 Oct 1998 02:20:13 DFT." <981005022013.ZM1469@candle.brasslantern.com>
`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 <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy
prev parent reply other threads:[~1998-10-05 9:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-10-04 23:18 Phil Pennock
1998-10-05 7:47 ` Peter Stephenson
1998-10-05 9:20 ` Bart Schaefer
1998-10-05 9:33 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9810050933.AA29858@ibmth.df.unipi.it \
--to=pws@ibmth.df.unipi.it \
--cc=phil@athenaeum.demon.co.uk \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).