Make test for gnuplot work with empty strings.
authorMartin Steigerwald <ms@teamix.de>
Mon, 5 Aug 2013 14:57:33 +0000 (08:57 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 5 Aug 2013 14:57:33 +0000 (08:57 -0600)
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>
tools/fio_generate_plots

index f65a326c87f52e6647a90988ade23ea092850da0..51c0643aaca3fb8b8d85a74926d46767daf46403 100755 (executable)
@@ -22,7 +22,7 @@ if [ -z "$1" ]; then
 fi
 
 GNUPLOT=$(which gnuplot)
-if [ ! -x $GNUPLOT ]
+if [ ! -x "$GNUPLOT" ]
 then
        echo You need gnuplot installed to generate graphs
        exit 1