From 8f294c43adf0df57ecda8319405355d1e2e7be1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sat, 14 Oct 2023 23:23:21 +0200 Subject: [PATCH] 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. --- bin/ruby-build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 2b85b24c..d3d6fbc7 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -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