summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-18 16:30:48 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-18 16:30:48 (EDT)
commit06f8ae1a6b17414e00f51e3db495daa1b66a9c15 (patch)
treedcc467aa48f0396749bfd9744bfbe51b3359b590 /lib
parent7e86caf5c2411a71be360ee2d99869a8b2e076b7 (diff)
ob_substvars(): Substitute binary package vars
Diffstat (limited to 'lib')
-rw-r--r--lib/control.sh19
1 files changed, 16 insertions, 3 deletions
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