From 70f491eae27ff5e66e81f9444e00f4b85bfc5e7f Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 1 Feb 2024 11:46:12 -0800 Subject: [PATCH] push-to-pull-request: Accept intermixed options and arguments again. Signed-off-by: Anders Kaseorg --- tools/push-to-pull-request | 52 +++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/tools/push-to-pull-request b/tools/push-to-pull-request index 38e584ed2b..8a09d2a979 100755 --- a/tools/push-to-pull-request +++ b/tools/push-to-pull-request @@ -27,32 +27,38 @@ EOF } merge= +args=() -while getopts ":-:" opt; do - case $opt in - -) - case "$OPTARG" in - help) - usage - exit 0 - ;; - merge) - merge=t - ;; - *) - echo "Invalid option: --$OPTARG" >&2 - exit 1 - ;; - esac - ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - exit 1 - ;; - esac +while ((OPTIND <= $#)); do + if getopts ":-:" opt; then + case $opt in + -) + case "$OPTARG" in + help) + usage + exit 0 + ;; + merge) + merge=t + ;; + *) + echo "Invalid option: --$OPTARG" >&2 + exit 1 + ;; + esac + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac + else + args+=("${!OPTIND}") + ((OPTIND++)) + fi done -shift $((OPTIND - 1)) +set -- "${args[@]}" remote_default="$(git config zulip.zulipRemote || echo upstream)" pseudo_remote="$(git config zulip.prPseudoRemote || echo)"