• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# Script to wait for jobs to complete.
4#
5# Copyright © 2008-2019 by Apple Inc.
6#
7# Licensed under Apache License v2.0.  See the file "LICENSE" for more
8# information.
9#
10
11#
12# Get timeout from command-line
13#
14
15if test $# = 1; then
16	timeout=$1
17else
18	timeout=360
19fi
20
21#
22# Figure out the proper echo options...
23#
24
25if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
26        ac_n=-n
27        ac_c=
28else
29        ac_n=
30        ac_c='\c'
31fi
32
33echo $ac_n "Waiting for jobs to complete...$ac_c"
34oldjobs=0
35
36while test $timeout -gt 0; do
37	jobs=`$runcups ../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '`
38	if test $jobs = 0; then
39		break
40	fi
41
42	if test $jobs != $oldjobs; then
43		echo $ac_n "$jobs...$ac_c"
44		oldjobs=$jobs
45	fi
46
47	sleep 5
48	timeout=`expr $timeout - 5`
49done
50
51echo ""
52