1#!/bin/sh 2# 3# Script to wait for jobs to complete. 4# 5# Copyright © 2020-2024 by OpenPrinting. 6# Copyright © 2008-2019 by Apple Inc. 7# 8# Licensed under Apache License v2.0. See the file "LICENSE" for more 9# information. 10# 11 12# 13# Get timeout from command-line 14# 15 16if test $# = 1; then 17 timeout=$1 18else 19 timeout=360 20fi 21 22# 23# Figure out the proper echo options... 24# 25 26if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then 27 ac_n=-n 28 ac_c= 29else 30 ac_n= 31 ac_c='\c' 32fi 33 34# 35# Check whether we have any jobs to wait for... 36# 37 38jobs=`$runcups ../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '` 39if test $jobs = 0; then 40 exit 0 41fi 42 43# 44# We do, let the tester know what is going on... 45# 46 47echo $ac_n "Waiting for jobs to complete...$ac_c" 48oldjobs=0 49 50while test $timeout -gt 0; do 51 jobs=`$runcups ../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '` 52 if test $jobs = 0; then 53 break 54 fi 55 56 if test $jobs != $oldjobs; then 57 echo $ac_n "$jobs...$ac_c" 58 oldjobs=$jobs 59 fi 60 61 sleep 5 62 timeout=`expr $timeout - 5` 63done 64 65echo "" 66