Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Is this possible in ZSH?
- X-seq: zsh-users 15543
- From: nix@xxxxxxxxxxxxxxxx
- To: zsh-users@xxxxxxx
- Subject: Is this possible in ZSH?
- Date: Sun, 14 Nov 2010 15:12:25 +0200
- Importance: Normal
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hi.
#!/bin/zsh
[CODE]
zmodload zsh/terminfo
emulate zsh
function Echo () {
# This function simulates background process that executes in a random period
#local A
#local B
A=$1
B=$2
sleep $B
echo "Key: $A Value: $B"
}
A=0
RANGE=15
while [ $A -lt 4 ] ; do
Rnd=$RANDOM
let "Rnd %= $RANGE"
# - Fork
Echo $A $Rnd & # <-----------
let "A++"
done
wait
[/CODE]
Is it possible to append background process results to a variable or to an
array without waiting for that job to finish? So as soon as "Echo"
function finishes, it´s results would be appended instead of file to
variable. I have tried it but every time it waited for the process until
it finished and i lost my multi-threading.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author