Unverified Commit 8f294c43 authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

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.
parent b54a73b1
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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