PostScript-equivalent to exit(EXIT_FAILURE) - How to exit PostScript with a non-zero exit value?

Viewed 33

I know the PostScript equivalent to exit(EXIT_SUCCESS), it is the quit operator. However, the quit operator does not take any arguments, it's just quit, and not 0 quit or 1 quit.

I'm looking for the PostScript equivalent to exit(EXIT_FAILURE). If necessary, it can be assumed that the PostScript interpreter is GhostScript.

It can furthermore be assumed that the normally discouraged behavior of quit of terminating the PostScript interpreter is not just accepted but even desired in this case.

1 Answers

Here's one way that appears to work with simple command line testing.

$ gsnd -q -c 'errordict/handleerror{stop}put (theres-no-file-with-this-name)run'
GPL Ghostscript 9.54.0: Unrecoverable error, exit code 1
$ echo $?
1

Calling run triggers the invalidfileaccess error requested by -dSAFER hidden in the gsnd script. Replacing errordict/handleerror suppresses the printing of the long error report.

Related