By default, if a script command results in an error, for example, because of a malformed command or invalid data format, processing continues. If you set
ON in a script and an error occurs during processing, the script terminates immediately.
=> \set ON_ERROR_STOP ON
If you invoke the script on Linux with
vsql -f, vsql returns with error code 3 to indicate that an error occurred in the script.