diff -Nru orig/grImport/R/PostScript2RGML.R patched/grImport/R/PostScript2RGML.R
--- orig/grImport/R/PostScript2RGML.R	2021-10-17 15:48:54.000000000 -0700
+++ patched/grImport/R/PostScript2RGML.R	2023-01-13 02:24:50.581333200 -0800
@@ -1145,7 +1145,7 @@
         if(is.null(gsexe) || !nzchar(gsexe)) {
             poss <- Sys.which(c("gswin64c.exe", "gswin32c.exe"))
             poss <- poss[nzchar(poss)]
-            gsexe <- if(length(poss)) poss else "gswin32c.exe"
+            gsexe <- if(length(poss)) poss[1] else "gswin32c.exe"
         } else if(grepl(" ", gsexe, fixed = TRUE))
             gsexe <- utils::shortPathName(gsexe)
         outfile <- tempfile()
@@ -1158,7 +1158,7 @@
         }
         outfile <- "/dev/null"
     }
-    cmd <- paste(gsexe, 
+    cmd <- paste(shQuote(gsexe), 
                  " -q -dBATCH -dNOPAUSE -dNOSAFER",
                  " -sDEVICE=ps2write -sOutputFile=",
                  outfile, " -sstdout=",
