blob: ec63e721425630927258638ba30f6efc1a4dff3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
# my For loop
# I can't find good one character name :(
# maybe rename it to loop
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
# tests?
#loop ls -lah -- -l
#loop printf 'echo 1; echo 2'
#loop printf 'haha %d lala' 10
# tips
#loop eval 'echo 1; echo 2'
|