commit b2c762854c93f9b02aadaa0d85a63038596733d5
parent c3a032531581e5596be91222f4f35f4967327129
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Thu, 10 Sep 2020 10:50:56 -0700
Reformat, shorten usage, and quote first argument.
Diffstat:
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/scripts/.local/bin/loop b/scripts/.local/bin/loop
@@ -1,30 +1,22 @@
#!/usr/bin/env dash
-# loops command indefinitly.
+# loops commands indefinitly.
-# display usage
-usage()
-{
- echo "usage, `basename $0` [-ih]"
- echo "\t-i, interactive, prompt at each iteration"
- echo "\t-e, errexit, exit on error"
- echo "\t-h, usage"
-}
+usage() { echo "usage, `basename $0` [-ehi]" ;}
while [ $# -ne 0 ]
do
- case $1
+ case "$1"
in
- -i) interactive=1; shift;;
- -e) set -e; shift;;
- -h) usage; exit 0;;
+ -i) shift; interactive=1;;
+ -h) usage; exit 1;;
+ -e) shift; set -e;;
*) break;;
esac
done
while true
do
- if [ ${interactive:=0} -eq 1 ]
- then
+ if [ ${interactive:=0} -eq 1 ]; then
read null || break
fi
eval $@