loop, make the function much more robust.

This commit is contained in:
me
2026-10-09 10:06:23 -07:00
parent a9080a6d12
commit f29fad4078
+11 -2
View File
@@ -1139,9 +1139,18 @@
} }
function_loop: | function_loop: |
function loop() { function loop() {
cmd="$1" cmd="$@"
sleep=""
sleep_time=5
if [[ "$cmd" != *"sleep"* ]]; then
sleep='echo -e "`date` - Sleeping for $sleep_time... \n"; sleep $sleep_time'
fi
count=0
while true; do while true; do
$cmd (( count++ ))
echo "`date` - Loop $count"
eval $cmd
eval $sleep
done; done;
} }
alias try="loop " alias try="loop "