summaryrefslogtreecommitdiff
path: root/sh/loop
blob: 6a578267e632274d62a7cd5162956bf4e603be18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

while getopts t: opt; do
	case $opt in
		t) time="$OPTARG";;
		\?) exit 1;;
	esac
done
shift $((OPTIND-1))

while :; do
	# suggested by https://github.com/koalaman/shellcheck/wiki/SC2294
	"$@"
	sleep "${time:-1}"
done