summaryrefslogtreecommitdiffhomepage
path: root/subr/pkgtool_init.subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-05-11 11:40:42 +0100
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2020-05-11 11:40:42 +0100
commit286c43af22d469fcbc7bef3f3bbca03de164acdf (patch)
tree1849b8c806624af1ce2ed9fbfc117ceab13b7334 /subr/pkgtool_init.subr
parent63eae076050d704eb568cc683523924861037611 (diff)
downloadmidipix_build-286c43af22d469fcbc7bef3f3bbca03de164acdf.tar.bz2
midipix_build-286c43af22d469fcbc7bef3f3bbca03de164acdf.tar.xz
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.
Diffstat (limited to 'subr/pkgtool_init.subr')
-rw-r--r--subr/pkgtool_init.subr28
1 files changed, 11 insertions, 17 deletions
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}";
};