summaryrefslogtreecommitdiffstats
path: root/lib/deps.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/deps.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/deps.sh')
-rw-r--r--lib/deps.sh32
1 files changed, 13 insertions, 19 deletions
diff --git a/lib/deps.sh b/lib/deps.sh
index 64553aa..348839a 100644
--- a/lib/deps.sh
+++ b/lib/deps.sh
@@ -79,37 +79,37 @@ ob_parse_dep()
p)
pkg_var="${OPTARG}"
if ! _ob_validate_var_name "${pkg_var}"; then
- return 125
+ _ob_abort
fi
;;
q)
archqual_var="${OPTARG}"
if ! _ob_validate_var_name "${archqual_var}"; then
- return 125
+ _ob_abort
fi
;;
r)
rel_var="${OPTARG}"
if ! _ob_validate_var_name "${rel_var}"; then
- return 125
+ _ob_abort
fi
;;
v)
ver_var="${OPTARG}"
if ! _ob_validate_var_name "${ver_var}"; then
- return 125
+ _ob_abort
fi
;;
A)
arches_var="${OPTARG}"
if ! _ob_validate_var_name "${arches_var}"; then
- return 125
+ _ob_abort
fi
;;
l)
plats_var="${OPTARG}"
if ! _ob_validate_var_name "${plats_var}"; then
- return 125
+ _ob_abort
fi
;;
a)
@@ -119,17 +119,14 @@ ob_parse_dep()
host_plat="${OPTARG}"
;;
?)
- return 125
+ _ob_abort
;;
esac
done
shift $(($OPTIND - 1))
- if [ ${#} -eq 1 ]; then
- dep="${1}"
- else
- return 125
- fi
+ dep="${1}"
+ shift 1 || _ob_abort
# pkg[:archqual] [(rel ver)] [\[arches\]] [<plats>]
dep_re='s/^ *([^ \(\[<]+) *(\((<<|<=|=|>=|>>) *(.+)\))?'
@@ -200,7 +197,7 @@ ob_parse_dep()
## Required.
## @option -u - Treat \fIdeps\fP as a union list.
## @operand deps req The list of dependencies to reduce.
-## @return Returns 0 on success or 125 on invalid option or missing \fIdeps\fP.
+## @return Returns 0 on success.
## @stdout Prints the reduced list of dependencies.
## @pure yes This function has no side effects.
ob_reduce_deps()
@@ -230,17 +227,14 @@ ob_reduce_deps()
union='true'
;;
?)
- return 125
+ _ob_abort
;;
esac
done
shift $(($OPTIND - 1))
- if [ ${#} -eq 1 ]; then
- deps="${1}"
- else
- return 125
- fi
+ local deps="${1}"
+ shift 1 || _ob_abort
IFS=','
for dep_and in ${deps}; do