summary refs log tree commit diff
diff options
context:
space:
mode:
-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"