Skip to content

E4. What foresight does not do ​

Goal: know where a script stops, and why it does not go on.

gnuplot
# a gnuplot command foresight does not have stops the script at its line, with its name
set terminal svg size 600,320
set output 'pe04.svg'
set loadpath 'macros'
plot sin(x)
console
$ foresight pe04_unsupported.gp; echo "returned $?"
foresight: pe04_unsupported.gp:6: unsupported option "set loadpath"
returned 1

The message names the file, the line (of the whole file) and the command; nothing is drawn after it.

Why it works ​

  • foresight interprets a subset of gnuplot and refuses the rest: a script that runs is a script that did what it says, not one that skipped a line. The list of what is not supported is short and kept current.
  • The commands that act on gnuplot's interactive windows only (bind, set mouse, vclear, test, set term push) are accepted and do nothing, as with gnuplot's file terminals: a script for the qt window runs as it is.
  • Messages that name a limit say what is supported instead: set palette: unsupported option "model XYZ" (RGB, HSV and CMY are supported, as gnuplot 6.0).

Try this ​

  • Comment the line out and run again; or put it in the gnuplot branch of E3.
  • foresight -e 'set loadpath "macros"' pe04_unsupported.gp: the same error, from the command line.

Pitfalls ​

  • The first refused line stops the script: fix it and the next one may stop it too. Run the script once with each fix, or read the list first.
  • --watch keeps watching after an error: fix the script, save it, and the next cycle runs it.

Reference: gnuplot subset. Next: E5. Checking against gnuplot.

foresight is available under your choice of license: GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT (License).