diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-07-20 16:45:11 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-07-20 16:50:53 -0700 |
commit | b6f9318c9bd2117de7f567dc8f50c56260015cc8 (patch) | |
tree | a1f26c4c2faa023a6eaaac070ebd94ef6df532f3 /src | |
parent | fb73b5c27b8b4e9ef171dc5665f11b8856a53117 (diff) | |
download | pandoc-b6f9318c9bd2117de7f567dc8f50c56260015cc8.tar.gz |
PDF: Better detection of a Cygwin environment.
Should close #5451.
Unlike the earlier fix, this one doesn't spill out to stderr
when 'uname -o' fails.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/PDF.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs index 5826f9856..6a1bb0862 100644 --- a/src/Text/Pandoc/PDF.hs +++ b/src/Text/Pandoc/PDF.hs @@ -42,6 +42,7 @@ import Text.Pandoc.Error (PandocError (PandocPDFProgramNotFoundError)) import Text.Pandoc.MIME (getMimeType) import Text.Pandoc.Options (HTMLMathMethod (..), WriterOptions (..)) import Text.Pandoc.Process (pipeProcess) +import System.Process (readProcessWithExitCode) import Text.Pandoc.Shared (inDirectory, stringify) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Walk (walkM) @@ -89,7 +90,13 @@ makePDF program pdfargs writer opts doc = -- user names (see #777) let withTempDir templ action = do tmp <- getTemporaryDirectory - if '~' `elem` tmp + uname <- E.catch + (do (ec, sout, _) <- readProcessWithExitCode "uname" ["-o"] "" + if ec == ExitSuccess + then return $ Just sout + else return Nothing) + (\(_ :: E.SomeException) -> return Nothing) + if '~' `elem` tmp || uname == Just "Cygwin" -- see #5451 then withTempDirectory "." templ action else withSystemTempDirectory templ action (newCommonState, res) <- liftIO $ withTempDir "tex2pdf." $ \tmpdir' -> do |