Allow inline arguments in --if conditions

Example:

    install_package openssl-1.1 "https://..." --if needs_openssl:1.0.1-3.1.x

In the example, the two values are passed as arguments to the `needs_openssl` function.
This commit is contained in:
Mislav Marohnić 2023-10-14 23:23:21 +02:00
parent b54a73b127
commit 8f294c43ad
No known key found for this signature in database

View file

@ -197,7 +197,12 @@ install_package_using() {
for arg in "${@:$(( package_type_nargs + 1 ))}"; do
if [ "$last_arg" = "--if" ]; then
"$arg" || return 0
if [[ $arg == *:* ]]; then
# Support colon-separated sub-argument, e.g. `needs_openssl:1.1`
"${arg%:*}" "$package_name" "${arg#*:}" || return 0
else
"$arg" "$package_name" || return 0
fi
elif [ "$arg" != "--if" ]; then
make_args["${#make_args[@]}"]="$arg"
fi