comparison tests/testlib/wait-on-file @ 44780:f727939f3513 stable

tests: use regular POSIX shell wait-on-file requires one POSIX extension (sleep with non-integral argument), but it doesn't require any bash extensions, so just require a normal POSIX shell. While here, use consistent formatting without redundant ; Differential Revision: https://phab.mercurial-scm.org/D8500
author Joerg Sonnenberger <joerg@bec.de>
date Thu, 07 May 2020 15:00:33 +0200
parents 23dd43d94f50
children 9d7d53771e5f
comparison
equal deleted inserted replaced
44779:b15a37d85dbe 44780:f727939f3513
1 #!/bin/bash 1 #!/bin/sh
2 # 2 #
3 # wait up to TIMEOUT seconds until a WAIT_ON_FILE is created. 3 # wait up to TIMEOUT seconds until a WAIT_ON_FILE is created.
4 # 4 #
5 # In addition, this script can create CREATE_FILE once it is ready to wait. 5 # In addition, this script can create CREATE_FILE once it is ready to wait.
6 6
20 create="" 20 create=""
21 if [ $# -eq 3 ]; then 21 if [ $# -eq 3 ]; then
22 create="$3" 22 create="$3"
23 fi 23 fi
24 24
25 if [ -n "$create" ]; 25 if [ -n "$create" ]; then
26 then
27 touch "$create" 26 touch "$create"
28 create="" 27 create=""
29 fi 28 fi
30 while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; 29 while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; do
31 do
32 timer=$(( $timer - 1)) 30 timer=$(( $timer - 1))
33 sleep 0.01 31 sleep 0.01
34 done 32 done
35 if [ "$timer" -le 0 ]; then 33 if [ "$timer" -le 0 ]; then
36 echo "file not created after $1 seconds: $wait_on" >&2 34 echo "file not created after $1 seconds: $wait_on" >&2