Make test for gnuplot work with empty strings.
authorMartin Steigerwald <ms@teamix.de>
Mon, 11 Mar 2013 15:22:56 +0000 (16:22 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 12 Mar 2013 12:16:00 +0000 (13:16 +0100)
commit8fdb9e22a8eb3cca928b3f44d60a9b710b291064
tree7a477d764e4ed5f3b4a441301bc4227e33add628
parent177380abbea4d8963513bd8ce1859bf3bc5a2f28
Make test for gnuplot work with empty strings.

When I launch fio_generate_plots on a system where gnuplot is not installed I
get this error :

$ fio_generate_plots test
Making bw logs
/usr/bin/fio_generate_plots: 42: /usr/bin/fio_generate_plots: -: not found

That's because the test checking whether gnuplot is installed is failing
because of an empty variable :
GNUPLOT=$(which gnuplot)
if [ ! -x $GNUPLOT ]; then
        echo You need gnuplot installed to generate graphs
        exit 1
fi

Indeed the command "test -x" is exiting with code 0.

To correct this we should enclose the variable with quotes :
if [ ! -x "$GNUPLOT" ]; then

Then the script is going into the test properly :
$ fio_generate_plots test
You need gnuplot installed to generate graphs

I copied problem description by Hervé from the Debian bug report below.

Fixes:
Bug#700580: /usr/bin/fio_generate_plots: -: not found
http://bugs.debian.org/700580

Reported-By: Hervé Werner <hwerner@score-md.com>
Tested-By: Hervé Werner <hwerner@score-md.com>
Tested-By: Martin Steigerwald <ms@teamix.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio_generate_plots