diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-18 17:39:30 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-18 17:39:30 (EDT) |
commit | 4ede09dc06f5c5abfe0aaf7408252239db075e49 (patch) | |
tree | 43fab3c11965c9663a05e0dd362c872f9a2c6602 /lib | |
parent | 92548d7de28f7adc0d4a513c8eb2ed3d45519c10 (diff) |
ob_substvars(): Make package operand optional
Diffstat (limited to 'lib')
-rw-r--r-- | lib/control.sh | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/control.sh b/lib/control.sh index 22ed8a5..ddd7cc9 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -256,15 +256,16 @@ ob_set_binary_substvar() ## variable substitutions is \fI${var}\fP, and substitutions can be ## nested. ## @operand string req The string in which to substitute variables. -## @operand package req The binary package for which to substitute variables. +## @operand package opt 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}" - local package="${2}" - shift 2 || _ob_abort + shift 1 || _ob_abort + local check_bin= + local package= local depth= local lhs= local name= @@ -272,6 +273,13 @@ ob_substvars() local old_rhs= local value= + check_bin=false + if [ ${#} -eq 1 ]; then + package="${1}" + shift 1 + check_bin=true + fi + # Logic inspired by that of dpkg's Dpkg::Substvars::substvars() # subroutine. @@ -318,7 +326,7 @@ ob_substvars() if eval "[ x\"\${_OB_SUBSTVAR_SRC_${name}:+set}\" = x'set' ]" then name="_OB_SUBSTVAR_SRC_${name}" - elif [ -n "${package}" ] && eval "[ x\"\${_OB_SUBSTVAR_BIN_$(: \ + elif ${check_bin} && eval "[ x\"\${_OB_SUBSTVAR_BIN_$(: \ )${package}__${name}:+set}\" = x'set' ]"; then name="_OB_SUBSTVAR_BIN_${package}__${name}" else |