summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-03-18 16:05:00 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-03-18 16:05:36 (EDT)
commit9c42c79d8789f2c8bf789cb8db47a35ee2221acc (patch)
treec908f22fe7dae40e23518510d2ae105165e8c33d /lib
parentc14e5780068625391ed8ef632b728add2e6c9ce5 (diff)
ob_set_source_substvar(): Make sed script a global var
Diffstat (limited to 'lib')
-rw-r--r--lib/control.sh19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/control.sh b/lib/control.sh
index cd982e9..37123dd 100644
--- a/lib/control.sh
+++ b/lib/control.sh
@@ -18,6 +18,15 @@
# along with opkbuild. If not, see <http://www.gnu.org/licenses/>.
_OB_SUBSTVARS_MAX_DEPTH=50
+_OB_SUBSTVAR_TRIM_SED='
+ 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/^[\n]*//; # remove leading newline characters,
+ s/[\n]*$//; # remove trailing newline characters, and
+ p; # print the results.
+ };
+'
_ob_parse_control_error()
{
@@ -200,15 +209,7 @@ ob_set_source_substvar()
name="$(printf '%s' "${name}" | tr 'a-z-' 'A-Z_')"
# Trim leading and trailing whitespace from value.
- value="$(printf '%s' "${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/^[\n]*//; # remove leading newline characters,
- s/[\n]*$//; # remove trailing newline characters, and
- p; # print the results.
- };
- ')"
+ value="$(printf '%s' "${value}" | sed -n "${_OB_SUBSTVAR_TRIM_SED}")"
eval "_OB_SUBSTVAR_${name}=\"\${value}\""