From 92ae4fc94e81d694ca1cb3637efd42101b2763e3 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 2 May 2020 21:30:15 -0400 Subject: Fix git-fetch-email argument parsing Shell script is hard. --- git-fetch-email.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/git-fetch-email.sh b/git-fetch-email.sh index 8fcb66d..83243c7 100644 --- a/git-fetch-email.sh +++ b/git-fetch-email.sh @@ -42,17 +42,19 @@ v,verbose log IMAP protocol to standard error " eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)" -for opt; do +while [ $# -gt 0 ]; do + opt=$1 + shift case "${opt}" in - (-C) cc=$2; shift;; - (-F) from=$2; shift;; - (-S) subject=$2; shift;; - (-T) to=$2; shift;; + (-C) cc=$1; shift;; + (-F) from=$1; shift;; + (-S) subject=$1; shift;; + (-T) to=$1; shift;; (-a) apply=1;; - (-h) host=$2; shift;; - (-m) mailbox=$2; shift;; - (-p) port=$2; shift;; - (-u) user=$2; shift;; + (-h) host=$1; shift;; + (-m) mailbox=$1; shift;; + (-p) port=$1; shift;; + (-u) user=$1; shift;; (-v) verbose=1;; (--no-apply) apply=;; (--no-cc) cc=;; @@ -62,7 +64,6 @@ for opt; do (--no-verbose) verbose=;; (--) break;; esac - shift done if [ -z "${user:-}" ]; then echo "${0}: username required" >&2 -- cgit 1.4.1