From 06f8ae1a6b17414e00f51e3db495daa1b66a9c15 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 18 Mar 2019 16:30:48 -0400 Subject: ob_substvars(): Substitute binary package vars --- (limited to 'lib') diff --git a/lib/control.sh b/lib/control.sh index 75a59d5..22ed8a5 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -255,14 +255,16 @@ ob_set_binary_substvar() ## \fBob_set_source_substvar\fP(3) in a string. The format for ## variable substitutions is \fI${var}\fP, and substitutions can be ## nested. -## @operand string req The string in which to substitute variables. +## @operand string req The string in which to substitute variables. +## @operand package req The binary package for which to substitute variables. ## @return Returns 0 on success or 1 on possible recursion. ## @stderr Prints a warning on possible recursion. ## @pure yes This function has no side effects. ob_substvars() { local string="${1}" - shift 1 || _ob_abort + local package="${2}" + shift 2 || _ob_abort local depth= local lhs= local name= @@ -313,7 +315,18 @@ ob_substvars() ${name} EOF )" - value="$(eval "printf '%s' \"\${_OB_SUBSTVAR_SRC_${name}}\"")" + if eval "[ x\"\${_OB_SUBSTVAR_SRC_${name}:+set}\" = x'set' ]" + then + name="_OB_SUBSTVAR_SRC_${name}" + elif [ -n "${package}" ] && eval "[ x\"\${_OB_SUBSTVAR_BIN_$(: \ + )${package}__${name}:+set}\" = x'set' ]"; then + name="_OB_SUBSTVAR_BIN_${package}__${name}" + else + _ob_warn_msg 'substvar_unknown' "${name}" + string="${lhs}${rhs}" + continue + fi + value="$(eval "printf '%s' \"\${${name}}\"")" string="${lhs}${value}${rhs}" depth=$((${depth} + 1)) done -- cgit v0.9.1