diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/control.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/control.sh b/lib/control.sh index 12dc8bd..15093a0 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -139,6 +139,36 @@ ${_obpco_line# }" return ${?} } +ob_set_substvar() +{ + _ob_local _obssv_name _obssv_value + + if [ ${#} -eq 2 ]; then + _obssv_name="${1}" + _obssv_value="${2}" + else + _ob_return 125 + return ${?} + fi + + # Trim leading and trailing whitespace from value. + _obssv_value="$(echo "${_obssv_value}" | sed -n ' + H; # Store each input line in the hold space. + ${ # At the last line of input, … + g; # … restore the hold space into the pattern space, … + s/^[ \t\n]*//; # … remove leading whitespace, … + s/[ \t\n]*$//; # … remove trailing whitespace, and … + p; # … print the results. + }; + ')" + + _obssv_name="$(echo "${_obssv_name}" | tr 'a-z-' 'A-Z_')" + eval "_OB_SUBSTVAR_${_obssv_name}='${_obssv_value}'" + + _ob_return 125 + return ${?} +} + _ob_parse_control_error() { _ob_local _obpcoe_file _obpcoe_line_nr _obpcoe_msg_id \ |