diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-18 00:51:50 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2019-03-18 00:51:50 (EDT) |
commit | 12736c48db116a1e72bfd799efa174f82f42b88e (patch) | |
tree | cf14934d1bb1696bb79d7a442bb9e7e5574dd3b2 | |
parent | d2d58afd0465fc2aafb58413305438f0c3226f8e (diff) |
Revert "ob_set_substvar(): Replace sed with read"
This reverts commit 96851fd522ae3540314ac5c5d4d4fbec1448ca4b.
-rw-r--r-- | lib/control.sh | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/control.sh b/lib/control.sh index b388705..78951bb 100644 --- a/lib/control.sh +++ b/lib/control.sh @@ -201,9 +201,16 @@ ob_set_substvar() )" # Trim leading and trailing whitespace from value. - read -r value <<-EOF - ${value} - EOF + # TODO: "read" can probably do this more simply. + value="$(echo "${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. + }; + ')" eval "_OB_SUBSTVAR_${name}=\"\${value}\"" |