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

Re: problem piping output of shell builtin



On Mon, Jan 05, 2004 at 07:26:15PM +0000, gj@xxxxxxxxxxxxxxxx wrote:
> Hi all,
> 
> I'm migrating from bash to zsh. It hasn't been so bad because I'm sort of new
> to shell programming anyways ( though I did have "fun" figuring out that zsh
> arrays start incrementing from 1 as opposed to bash's 0 :). I thought I'd
> share the latest hiccup...
> 
> Why can't I pipe the output of 'jobs' thusly?
> 
> 	% zsh --version
> 	zsh 4.0.7 (alpha--netbsd)
> 	% sleep 100
> 	^Z
> 	zsh: suspended  sleep 100
> 	% sleep 100
> 	^Z
> 	zsh: suspended  sleep 100
> 	% jobs
> 	[1]    suspended  pine
> 	[2]  - suspended  sleep 100
> 	[3]  + suspended  sleep 100
> 	% jobs | while read line; do echo $line; done
> 	%
> 
> I expect the output of last sequence of commands to be more or less the same
> to the sequence before it, as under bash. How can I approximate the bashlike
> behavior I expect under zsh?
> 
> Thanks for any insight,
> Gerald.

That's interesting.  I get the same result as you on zsh-4.0.9 but
when I tried it on zsh-4.1.0-dev-5 it works properly.

<test>
$ zsh --version 
zsh 4.1.0-dev-5 (i386-portbld-freebsd5.0)
$ sleep 100
^Z
zsh: suspended  sleep 100
$ sleep 100
^Z
zsh: suspended  sleep 100
$ jobs | while read line; do echo $line; done
[1]  - suspended  sleep 100
[2]  + suspended  sleep 100
$
</test>

However, if I pipe the output of some other command like "ls", to the
while loop, it works fine.  The problem seems to only be when piping
the output of jobs.

Vincent

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
http://www.InetAddresses.net



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