Closed econnell closed 10 years ago
Arguably, bats is performing correctly here, and this is a bug that should be filed against redis-cli.
I'm not sure it's Bats' job to normalize line endings.
If you want to strip all carriage returns from the output string:
output="${output//$'\r'}"
While writing a test that relied out the output of redis-cli, I was having issues matching the $output variable. Finally, echoing $output through cat -vt showed me there was a \r (^M) stuck on the end of the line.
redis-cli outputs \r\n as line endings even on unix systems for some odd reason.
As a workaround, i piped it through perl -pe 's/\W*$//'
You can test this by running:
run echo -en "0\r\n" echo "output: $output" | cat -vt [ "$output" = "0" ] # fails