about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-03 02:08:44 -0500
committerJune McEnroe <june@causal.agency>2020-03-03 02:08:44 -0500
commit513579b749e260d3451bfae57bcb6f17526b4e82 (patch)
treeb58a406a1006b88009632a968ab7e23d306f2865
parentCall fopencookie with a+ (diff)
downloadimbox-513579b749e260d3451bfae57bcb6f17526b4e82.tar.gz
imbox-513579b749e260d3451bfae57bcb6f17526b4e82.zip
Use getopts
-rw-r--r--git-fetch-email.sh23
1 files changed, 10 insertions, 13 deletions
diff --git a/git-fetch-email.sh b/git-fetch-email.sh
index 704651b..80b3bb7 100644
--- a/git-fetch-email.sh
+++ b/git-fetch-email.sh
@@ -26,22 +26,19 @@ from=$(git config fetchemail.from)
 to=$(git config fetchemail.to)
 cc=$(git config fetchemail.cc)
 
-args=$(getopt 'C:F:S:T:h:m:p:' $*)
-[ $? -ne 0 ] && exit 1
-set -- $args
-for opt; do
-	shift;
+while getopts 'C:F:S:T:h:m:p:' opt; do
 	case "$opt" in
-		(-C) cc=$1; shift;;
-		(-F) from=$1; shift;;
-		(-S) subject=$1; shift;;
-		(-T) to=$1; shift;;
-		(-h) host=$1; shift;;
-		(-m) mailbox=$1; shift;;
-		(-p) port=$1; shift;;
-		(--) break;;
+		(C) cc=$OPTARG;;
+		(F) from=$OPTARG;;
+		(S) subject=$OPTARG;;
+		(T) to=$OPTARG;;
+		(h) host=$OPTARG;;
+		(m) mailbox=$OPTARG;;
+		(p) port=$OPTARG;;
+		(?) exit 1;;
 	esac
 done
+shift $(($OPTIND - 1))
 [ $# -ne 0 ] && user=$1
 if [ -z "${user:-}" ]; then
 	echo "$0: username required"