echo cart | { IFS= read -r spo; printf '%s\
' "$spo"; }
Would work (store the output of `echo` without the trailing newline character into the `spo` variable) as long as `echo` outputs only one line.
You could always do:
assign() {
eval "$1=\$(cat; echo .); $1=\${$1%.}"
}
assign spo < <(echo cart)
The following solutions would work in `bash` scripts, but not at the `bash` prompt:
shopt -s lastpipe
echo cat | assign spo
Or:
shopt -s lastpipe
whatever | IFS= read -rd '' spo
To store the output of `whatever` up to the first NUL characters (`bash` variables can't store NUL characters anyway) in `$spo`.
Or:
shopt -s lastpipe
whatever | readarray -t spo
to store the output of `whatever` in the `$spo` _array_ (one line per array element).