From 286c43af22d469fcbc7bef3f3bbca03de164acdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Mon, 11 May 2020 11:40:42 +0100 Subject: subr/build_init.subr:buildp_init_getopts(): allow mixing non-option arguments w/ options. subr/pkgtool_init.subr:pkgtoolp_init_getopts(): allow mixing non-option arguments w/ options. --- subr/pkgtool_init.subr | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'subr/pkgtool_init.subr') diff --git a/subr/pkgtool_init.subr b/subr/pkgtool_init.subr index 10650b41..bcbe455e 100644 --- a/subr/pkgtool_init.subr +++ b/subr/pkgtool_init.subr @@ -59,26 +59,20 @@ pkgtoolp_init_getopts() { t) ARG_TARBALL=1; ;; *) cat etc/pkgtool.usage; exit 1; ;; esac; shift $((${OPTIND}-1)); OPTIND=1; - else - break; + else case "${1}" in + *=*) rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; + *) if [ -n "${PKGTOOL_PKG_NAME:-}" ]; then + _rc=1; _status="Error: more than one package name specified."; + else + PKGTOOL_PKG_NAME="${1}"; + fi; ;; + esac; shift; fi; done; if [ "${_rc}" -eq 0 ]; then - while [ "${#}" -gt 0 ]; do - case "${1}" in - *=*) rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;; - *) if [ "${#}" -ne 1 ]; then - _rc=1; _status="Error: invalid command line \`${*}'."; - fi; break; ;; - esac; shift; - done; - if [ "${_rc:-0}" -eq 0 ]; then - if [ "${#}" -ne 1 ]\ - && [ -z "${PKGTOOL_PKG_NAME:-}" ]; then - _rc=1; _status="Error: missing package name."; - elif [ "${#}" -eq 1 ]; then - PKGTOOL_PKG_NAME="${1}"; export PKGTOOL_PKG_NAME; - fi; + if [ -z "${PKGTOOL_PKG_NAME:-}" ]; then + _rc=1; _status="Error: missing package name."; + else export PKGTOOL_PKG_NAME; fi; fi; return "${_rc}"; }; -- cgit v1.2.3