diff options
-rw-r--r-- | lib/control.sh | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/control.sh b/lib/control.sh index 248b422..d8d9bd2 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -203,16 +203,16 @@ ob_set_source_substvar() local value="${2}" shift 2 || _ob_abort - # Convert variable name to uppercase and validate. + # Validate variable name and convert to lower case. case "${name}" in *[!A-Za-z0-9-]* | '') return 1 esac - name="$(printf '%s' "${name}" | tr 'a-z-' 'A-Z_')" + name="$(printf '%s' "${name}" | tr 'A-Z-' 'a-z_')" # Trim leading and trailing whitespace from value. value="$(printf '%s' "${value}" | sed -n "${_OB_SUBSTVAR_TRIM_SED}")" - eval "_OB_SUBSTVAR_SRC_${name}=\"\${value}\"" + eval "_ob_substvar_src_${name}=\"\${value}\"" return 0 } @@ -235,21 +235,21 @@ ob_set_binary_substvar() local package="${3}" shift 3 || _ob_abort - # Convert variable name to uppercase and validate. + # Validate variable name and convert to lower case. case "${name}" in *[!A-Za-z0-9-]* | '') return 1 esac - name="$(printf '%s' "${name}" | tr 'a-z-' 'A-Z_')" + name="$(printf '%s' "${name}" | tr 'A-Z-' 'a-z_')" # Trim leading and trailing whitespace from value. value="$(printf '%s' "${value}" | sed -n "${_OB_SUBSTVAR_TRIM_SED}")" # Convert package name to clean form. - package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | tr -dC 'A-Z0-9')" + package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | tr -dC 'a-z0-9')" # TODO: Maybe disallow variable names beginning with hyphens, and/or # otherwise make this safer. - eval "_OB_SUBSTVAR_BIN_${package}__${name}=\"\${value}\"" + eval "_ob_substvar_bin_${package}__${name}=\"\${value}\"" return 0 } @@ -324,15 +324,15 @@ ob_substvars() esac # Perform the substitution. - name_tr="$(printf '%s' "${name}" | tr 'a-z-' 'A-Z_')" - package="$(printf '%s' "${package}" | tr 'a-z' 'A-Z' | \ - tr -dC 'A-Z0-9')" - if eval "[ x\"\${_OB_SUBSTVAR_SRC_${name_tr}:+set}\" = x'set' ]" + name_tr="$(printf '%s' "${name}" | tr 'A-Z-' 'a-z_')" + package="$(printf '%s' "${package}" | tr 'A-Z' 'a-z' | \ + tr -dC 'a-z0-9')" + if eval "[ x\"\${_ob_substvar_src_${name_tr}:+set}\" = x'set' ]" then - name_tr="_OB_SUBSTVAR_SRC_${name_tr}" - elif ${check_bin} && eval "[ x\"\${_OB_SUBSTVAR_BIN_$(: \ + name_tr="_ob_substvar_src_${name_tr}" + elif ${check_bin} && eval "[ x\"\${_ob_substvar_bin_$(: \ )${package}__${name_tr}:+set}\" = x'set' ]"; then - name_tr="_OB_SUBSTVAR_BIN_${package}__${name_tr}" + name_tr="_ob_substvar_bin_${package}__${name_tr}" else _ob_warn_msg 'substvar_unknown' "${name}" string="${lhs}${rhs}" |