push-to-pull-request: Use getopts for macOS compatibility.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-01-31 22:32:12 -08:00 committed by Tim Abbott
parent 130aecbf9e
commit 474703a963
1 changed files with 21 additions and 15 deletions

View File

@ -26,28 +26,34 @@ See also \`reset-to-pull-request\`.
EOF EOF
} }
args="$(getopt -o '' --long help,merge -n "$0" -- "$@")"
eval "set -- $args"
merge= merge=
while true; do while getopts ":-:" opt; do
case "$1" in case $opt in
--help) -)
usage case "$OPTARG" in
exit 0 help)
usage
exit 0
;;
merge)
merge=t
;;
*)
echo "Invalid option: --$OPTARG" >&2
exit 1
;;
esac
;; ;;
--merge) \?)
merge=t echo "Invalid option: -$OPTARG" >&2
shift exit 1
;;
--)
shift
break
;; ;;
esac esac
done done
shift $((OPTIND - 1))
remote_default="$(git config zulip.zulipRemote || echo upstream)" remote_default="$(git config zulip.zulipRemote || echo upstream)"
pseudo_remote="$(git config zulip.prPseudoRemote || echo)" pseudo_remote="$(git config zulip.prPseudoRemote || echo)"