Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

push-to-pull-request: Accept intermixed options and arguments again.

Anders Kaseorg70f491eae27f
diff --git a/tools/push-to-pull-request b/tools/push-to-pull-request
index 38e584ed2b6..8a09d2a9796 100755
--- a/tools/push-to-pull-request
+++ b/tools/push-to-pull-request
@@ -27,32 +27,38 @@ EOF
}
merge=
-
-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
+args=()
+
+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)"