- Ubuntu 10.10
- GNU bash, version 4.1.5(1)-release (i686-pc-linux-gnu)
- redis-cli shipped with Redis verison 2.0.0
This script does work:
#! /bin/bash
set -e
f=$(echo 'bgrewriteaof_in_progress:0' | grep bgrewriteaof_in_progress | cut -d':' -f2)
test "${f}" = "0" && echo y || echo n
echo $f
Prints:
y 0
This script does not work:
#! /bin/bash
set -e
f=$(redis-cli info | grep bgrewriteaof_in_progress | cut -d':' -f2)
test "${f}" = "0" && echo y || echo n
echo $f
Prints:
n 0
How is this possible? (Note that echo $f
prints 0
, so the result is there.)