I would like to have a gnuplot script which may or may not plot a file depending on some condition. Using /dev/null if I don’t have to plot a file works, but gives a “Skipping data file with no valid points” warning that I would like to silence.
test.gp:
#! /usr/bin/env gnuplot
file1 = "file1.txt"
file2 = |ARGV| > 0 ? ARG1 : "/dev/null"
plot file1, file2
If I call it with no argument, it only plots "file1.txt"
, which is the intended behaviour — but it also outputs "test.gp" line 6: warning: Skipping data file with no valid points
. Is there anything else I can use as file2
instead of "/dev/null"
which will also not plot anything but not result into any warning? (I’d rather not just use gnuplot test.gp 2> /dev/null
because I do want to see any warnings about anything else in the script.)