The details differ by platform. On a Unix-alike, the GhostScript executable is usually called
gs. The name (and possibly path) of the command is taken
first from argument gs_cmd
then from the environment variable
R_GSCMD and default gs
. This is then looked for on the
system path and the value returned if a match is found.
On Windows, the name of the command is taken from argument
gs_cmd
then from the environment variables R_GSCMD and
GSC. If neither of those produces a suitable command name,
gswin64c and gswin32c are tried in turn. In all
cases the command is looked for on the system PATH.
Note that on Windows (and some other OSes) there are separate
GhostScript executables to display Postscript/PDF files and to
manipulate them: this function looks for the latter.