aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-05-12 21:00:33 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2016-05-12 21:00:33 -0700
commit5d8d8b0de1ebf1ffd9bdff8086a524a5ff614dff (patch)
treeee656e4e47162534065904146ff6f9e5f82f55fd
parent1b8d006ac848d146a4b29167f9037306bfaae559 (diff)
downloadpandoc-5d8d8b0de1ebf1ffd9bdff8086a524a5ff614dff.tar.gz
Revert "Use shell instead of proc to check for latex program."
This reverts commit ee45be5723ef6001ae333110ce45ae2f7b1b17af.
-rw-r--r--pandoc.hs36
1 files changed, 7 insertions, 29 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 78dcd6840..76803be43 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -52,14 +52,8 @@ import Data.Char ( toLower, toUpper )
import Data.List ( delete, intercalate, isPrefixOf, isSuffixOf, sort )
import System.Directory ( getAppUserDataDirectory, findExecutable,
doesFileExist, Permissions(..), getPermissions )
-import System.Process ( shell, CreateProcess(..),
- waitForProcess, StdStream(CreatePipe) )
-#if MIN_VERSION_process(1,2,1)
-import System.Process ( createProcess_ )
-#else
-import System.Process.Internals ( createProcess_ )
-#endif
-import System.IO ( stdout, stderr, hClose )
+import System.Process ( readProcessWithExitCode )
+import System.IO ( stdout, stderr )
import System.IO.Error ( isDoesNotExistError )
import qualified Control.Exception as E
import Control.Exception.Extensible ( throwIO )
@@ -1408,8 +1402,11 @@ convertWithOpts opts args = do
_ | html5Output -> "wkhtmltopdf"
_ -> latexEngine
-- check for pdf creating program
- progExists <- checkProg pdfprog
- when (not progExists) $
+ (ec,_,_) <- E.catch
+ (readProcessWithExitCode pdfprog ["--version"] "")
+ (\(_ :: E.SomeException) ->
+ return (ExitFailure 1,"",""))
+ when (ec /= ExitSuccess) $
err 41 $ pdfprog ++ " not found. " ++
pdfprog ++ " is needed for pdf output."
@@ -1431,22 +1428,3 @@ convertWithOpts opts args = do
handleEntities = if htmlFormat && ascii
then toEntities
else id
-
--- Check for existence of prog by doing prog --version.
-checkProg :: String -> IO Bool
-checkProg "" = return False
-checkProg prog = E.handle handleErr $ do
- (_,Just o,Just e,p) <- createProcess_ "system"
- (shell (prog ++ " --version")){
- delegate_ctlc = True,
- std_out = CreatePipe,
- std_err = CreatePipe
- }
- ec <- waitForProcess p
- hClose o
- hClose e
- if ec == ExitSuccess
- then return True
- else return False
- where handleErr :: E.SomeException -> IO Bool
- handleErr _ = return False