aboutsummaryrefslogtreecommitdiff
path: root/bin/forever
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-11-14 00:20:14 -0300
committerEuAndreh <eu@euandre.org>2024-11-14 00:20:14 -0300
commitd79b04879e8139e79ed72972bc84292608184b94 (patch)
tree6b2567352ed01fa82d0d845bc73507f0c093d9cf /bin/forever
parentbin/clean: Shrink to the minimum (diff)
downloaddotfiles-d79b04879e8139e79ed72972bc84292608184b94.tar.gz
dotfiles-d79b04879e8139e79ed72972bc84292608184b94.tar.xz
bin/forever: Add "-n" option, remove long options
Diffstat (limited to 'bin/forever')
-rwxr-xr-xbin/forever52
1 files changed, 7 insertions, 45 deletions
diff --git a/bin/forever b/bin/forever
index c323086..4318681 100755
--- a/bin/forever
+++ b/bin/forever
@@ -4,60 +4,21 @@ set -eu
usage() {
cat <<-'EOF'
Usage:
- forever [-q] COMMAND...
- forever -h
+ forever [-n SECONDS] [-q] COMMAND...
EOF
}
-help() {
- cat <<-'EOF'
-
-
- Options:
- -q quiet mode, don't print exit code messages
- -h, --help show this message
-
- COMMAND shell command to be wrapped
-
-
- Run COMMAND forever.
-
-
- Examples:
-
- Print 123 forever:
-
- $ forever echo 123
- EOF
-}
-
-
-for flag in "$@"; do
- case "$flag" in
- (--)
- break
- ;;
- (--help)
- usage
- help
- exit
- ;;
- (*)
- ;;
- esac
-done
+_SECONDS=5
QUIET=false
-while getopts 'qh' flag; do
+while getopts 'n:q' flag; do
case "$flag" in
+ (n)
+ _SECONDS="$OPTARG"
+ ;;
(q)
QUIET=true
;;
- (h)
- usage
- help
- exit
- ;;
(*)
usage >&2
exit 2
@@ -75,4 +36,5 @@ while true; do
if [ "$QUIET" = false ]; then
printf 'Exitted with code %s.\n' "$STATUS" >&2
fi
+ sleep "$_SECONDS"
done