bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Job queing


From: Mårten Segerkvist
Subject: Re: Job queing
Date: Mon, 21 Aug 2006 18:45:26 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060728)

Having discovering 'trap' I scripted this:

declare -a queue[]
function q() {
 queue[${#queue[@]}]="cd `pwd` && $@"
}
function runq() {
 if [ -n "$queue" ]; then
   local command=$queue
   queue=("${queue[@]:1}")
   bash -c "($command; kill -33 $$)" &
 fi
}
trap 'runq' 33

which works almost as intended...

Bob Proulx, 08/21/06 17:23:
Mårten Segerkvist wrote:
command1 &
%1 && command2 &
%2 && command3

(where the second command line awaits the execution of the first etc.)

In a script you can grab the process id of the last background job
with $!.  Then you can wait for that job id.

  command &
  wait $! && command2 &
  wait $! && command3 &

Just an idea...

Bob







reply via email to

[Prev in Thread] Current Thread [Next in Thread]