From 285bbf61cf2b21278792e48aee7c25fa0ee62faa Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 9 May 2016 20:52:20 -0700 Subject: [PATCH] New method for checking for presence of tex program. Now instead of using `findExecutable`, which has limitations on Windows, we just do `progname --version` and see if it returns successfully. Closes #2903. --- pandoc.cabal | 3 ++- pandoc.hs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandoc.cabal b/pandoc.cabal index e8252293b..677fb31ac 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -424,7 +424,8 @@ Executable pandoc aeson >= 0.7.0.5 && < 0.12, yaml >= 0.8.8.2 && < 0.9, containers >= 0.1 && < 0.6, - HTTP >= 4000.0.5 && < 4000.4 + HTTP >= 4000.0.5 && < 4000.4, + process >= 1.0 && < 1.5 if flag(network-uri) Build-Depends: network-uri >= 2.6 && < 2.7, network >= 2.6 else diff --git a/pandoc.hs b/pandoc.hs index b686dbb90..56fa2c05f 100644 --- a/pandoc.hs +++ b/pandoc.hs @@ -52,6 +52,7 @@ import Data.Char ( toLower, toUpper ) import Data.List ( delete, intercalate, isPrefixOf, isSuffixOf, sort ) import System.Directory ( getAppUserDataDirectory, findExecutable, doesFileExist, Permissions(..), getPermissions ) +import System.Process ( readProcessWithExitCode ) import System.IO ( stdout, stderr ) import System.IO.Error ( isDoesNotExistError ) import qualified Control.Exception as E @@ -1401,8 +1402,8 @@ convertWithOpts opts args = do _ | html5Output -> "wkhtmltopdf" _ -> latexEngine -- check for pdf creating program - mbPdfProg <- findExecutable pdfprog - when (isNothing mbPdfProg) $ + (ec,_,_) <- readProcessWithExitCode pdfprog ["--version"] "" + when (ec /= ExitSuccess) $ err 41 $ pdfprog ++ " not found. " ++ pdfprog ++ " is needed for pdf output."