summaryrefslogtreecommitdiffstats
path: root/lib/package
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-13 02:51:56 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-13 02:56:19 (EDT)
commit9033d4b6b9b85ab3e502b376daf66ae566c026b6 (patch)
tree5933fa9a313caff0ec5a0aa38e4087cba777c6d8 /lib/package
parente153a4a392e2f6e616b2c94b77eb683eff9e644a (diff)
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.
Diffstat (limited to 'lib/package')
-rw-r--r--lib/package/2.sh23
1 files changed, 8 insertions, 15 deletions
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}"