From 9033d4b6b9b85ab3e502b376daf66ae566c026b6 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 02:51:56 -0400 Subject: libopkbuild: Abort on invalid function arguments Shift arguments and abort instead of returning 125. Incorrect numbers of function arguments suggest application/library incompatibilities or serious errors by the application developer. Either way, the application developer should be made immediately aware of this (and not allowed to simply not check return values), and continuing to run and handle any further API calls may be unsafe. --- (limited to 'lib/package') diff --git a/lib/package/2.sh b/lib/package/2.sh index 551f199..3e362f4 100644 --- a/lib/package/2.sh +++ b/lib/package/2.sh @@ -70,7 +70,7 @@ _ob_srcfield_2() local name="${1}" local value="${2}" local user_data="${3}" - shift 3 + shift 3 || _ob_abort _ob_set_source_parameter "${name}" "${value}" @@ -95,7 +95,7 @@ _ob_binfield_2() local name="${1}" local value="${2}" local pkg="${3}" - shift 3 + shift 3 || _ob_abort _ob_set_binary_parameter "${pkg}" "${name}" "${value}" @@ -127,13 +127,11 @@ _ob_get_doc_package_2() _ob_get_doc_files_2() { - local arch= - local plat= + local arch="${1}" + local plat="${2}" + shift 2 || _ob_abort local doc_pkg= - arch="${1}" - plat="${2}" - doc_pkg="$(_ob_get_doc_package_2)" cat <<-EOF @@ -148,13 +146,8 @@ _ob_get_doc_files_2() _ob_set_package_substvars_2() { - local pkg= - - if [ ${#} -eq 1 ]; then - pkg="${1}" - else - return 125 - fi + local pkg="${1}" + shift 1 || _ob_abort if [ -f "${_OB_PACKAGE_DIR}/substvars" ]; then ob_parse_control "${_OB_PACKAGE_DIR}/substvars" \ @@ -174,7 +167,7 @@ _ob_substvar_2() local name="${1}" local value="${2}" local user_data="${3}" - shift 3 + shift 3 || _ob_abort ob_set_substvar "${name}" "${value}" -- cgit v0.9.1