Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: problem piping output of shell builtin
- X-seq: zsh-users 6980
- From: Pavol Juhas <juhas@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: problem piping output of shell builtin
- Date: Mon, 5 Jan 2004 15:36:38 -0500
- In-reply-to: <Pine.NEB.4.58.0401051856430.2690@xxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Pine.NEB.4.58.0401051856430.2690@xxxxxxxxxxxxxxxxxxx>
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?
AFAIK, all the shells run one side of the pipe in a subshell. bash
executes subshell for the right side of the pipe, however zsh does
so for the left side. Therefore the `jobs' command in
`jobs|read line' is evaluated in the subshell of zsh, which has no
knowledge about processes in the parent shell - and produces no
output. Left side subshell is however advantageous in other
situations, just compare
zsh -c 'echo 10|read a; echo .$a'
.10
bash -c 'echo 10|read a; echo .$a'
.
To access information in the zsh job table, you need to use the
builtin associate arrays jobtexts, jobstates and jobdirs, for example:
for j in ${(k)jobstates}; do
print -- "[$j] ${jobstates[$j]} ${jobtexts[$j]} in ${jobdirs[$j]}"
done
HTH,
Pavol
Messages sorted by:
Reverse Date,
Date,
Thread,
Author