summaryrefslogtreecommitdiffstats
path: root/lib/changelog.sh
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/changelog.sh
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/changelog.sh')
-rw-r--r--lib/changelog.sh26
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/changelog.sh b/lib/changelog.sh
index 7cb6c0b..3216f94 100644
--- a/lib/changelog.sh
+++ b/lib/changelog.sh
@@ -19,16 +19,12 @@
_ob_parse_changelog_error()
{
- local file=
- local line_nr=
- local msg_id=
+ local file="${1}"
+ local line_nr="${2}"
+ local msg_id="${3}"
+ shift 3 || _ob_abort
local file_info=
- file="${1}"
- line_nr="${2}"
- msg_id="${3}"
- shift 3
-
file_info="$(printf '%20s(l%d)' "${file}" "${line_nr}")"
_ob_warn_msg "${msg_id}" "${file_info}" "${@}"
@@ -57,15 +53,16 @@ _ob_get_changelog_expect_str()
## \fIchangelog\fP file or when \fIentry_cb\fP returns non-zero.
## @operand file req The file to parse, or "-" for standard input.
## @operand entry_cb req Callback to run for each entry.
-## @return Returns 0 after parsing, or 125 on missing arguments.
+## @return Returns 0 after parsing.
## @stderr Prints error messages on parse errors.
## @pure maybe This function has no side effects. Whether this function is
## subshell-safe in practice depends on whether \fIentry_cb\fP is
## subshell-safe.
ob_parse_changelog()
{
- local file=
- local entry_cb=
+ local file="${1}"
+ local entry_cb="${2}"
+ shift 2 || _ob_abort
local line_nr=
local line=
local line_=
@@ -78,13 +75,6 @@ ob_parse_changelog()
local maintainer=
local date=
- if [ ${#} -eq 2 ]; then
- file="${1}"
- entry_cb="${2}"
- else
- return 125
- fi
-
# Parsing logic based on that of dpkg.
line_nr=0