Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: cat file|while read behaves not as expected
- X-seq: zsh-users 5350
- From: Paul Lew <paullew@xxxxxxxxx>
- To: Micha Holzmann <holzmann@xxxxxxxx>
- Subject: RE: cat file|while read behaves not as expected
- Date: Sun, 15 Sep 2002 23:52:16 -0700
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20020916063254.GA8555@xxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20020916063254.GA8555@xxxxxxxxxxxxxxxxxxxx>
>>>>> "Micha" == Micha Holzmann <holzmann@xxxxxxxx> writes:
Micha> #!/bin/zsh
Micha> cat ./tst.dat|while read line
Micha> do
Micha> for i in $line
Micha> do
Micha> echo $i
Micha> done
Micha> done
Micha> If i run this script, it prints "1 2 3 4 5" as result, if i
Micha> change the shell to /bin/sh, it prints (te expected)
Micha> result:
Micha> 1
Micha> 2
Micha> 3
Micha> 4
Micha> 5
Micha> What is the fault i make?
if you say:
for i in $=line
it will do what you want. Basically, the variable i will contain the
"1 2 3 4 5", unless you told it to split word, the entire entry is
will be used on variable expansion. This is what zsh does it
correctly compare to other shells, but also a problem with
compatibility :-)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author