s4-registry: Don't leak memory on error.
[Samba/bjacke.git] / script / random-sleep.sh
blob9bb866b3e09a2d5af3c06ce46eec03be614b575d
1 #!/bin/sh
4 if [ $# -lt 2 ]; then
5 echo "$0: <low> <high>"
6 exit 1;
7 fi
9 l=$1
10 h=$2
12 s=$(expr $h - $l)
14 r=$(head --bytes=2 /dev/urandom | od -l | head -n 1 | sed -e 's/^[^ ]* *//')
16 v=$(expr $r % $s)
17 d=$(expr $l + $v)
19 echo "$0: sleep $d ... start"
20 sleep $d
21 echo "$0: sleep $d ... end"