How can I pipe the output of a program or function into a variable?
For example lets say I have this script:
function foobarize () {
sed \
-e "s|${foo}|${bar}|g" \
$1
}
echo foo | foobarize | set THIS_VARIABLE
Obviously it won't work to set the value of THIS_VARIABLE.
But if I do:
THIS_VARIABLE=$(echo foo | foobarize)
... that doesn't work either because it strips any trailing newlines.
So how do I get the output of foobarize into THIS_VARIABLE without using back-ticks or $() ?