git.iko.soy/typeable/pandoc
on master help sign in
Behave gracefully if HOME is not set.

If getAppUserDataDirectory raises an error, just use the default data files. Previously pandoc *assumed* HOME was set and would error out if not. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1842 788f1e2b-df1e-0410-8736-df70ead52e1b

commit40ea955e23a684173f8f390d2e63980d7727d71c authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 21 Feb 2010, 16:47 (17 years ago) parentf9c6908
1 file changed+9−7
src/pandoc.hs+9−7
src/pandoc.hs+9−7
@@ -58,7 +58,7 @@ import System.IO.UTF8
5858import Text.CSL
5959import Text.Pandoc.Biblio
6060#endif
61−import Control.Monad (when, unless)
61+import Control.Monad (when, unless, liftM)
6262import Network.HTTP
6363import Network.URI (parseURI)
6464import Data.ByteString.Lazy.UTF8 (toString)
@@ -633,8 +633,10 @@ main = do
633633 let sources = if ignoreArgs then [] else args
634634
635635 datadir <- case mbDataDir of
636− Just d -> return d
637− Nothing -> getAppUserDataDirectory "pandoc"
636+ Nothing -> catch
637+ (liftM Just $ getAppUserDataDirectory "pandoc")
638+ (const $ return Nothing)
639+ Just _ -> return mbDataDir
638640
639641 -- assign reader and writer based on options and filenames
640642 let readerName' = if null readerName
@@ -653,7 +655,7 @@ main = do
653655 Just r -> return r
654656 Nothing -> error ("Unknown writer: " ++ writerName')
655657
656− templ <- getDefaultTemplate (Just datadir) writerName'
658+ templ <- getDefaultTemplate datadir writerName'
657659 let defaultTemplate = case templ of
658660 Right t -> t
659661 Left e -> error (show e)
@@ -671,13 +673,13 @@ main = do
671673
672674 variables' <- if writerName' == "s5" && standalone'
673675 then do
674− inc <- s5HeaderIncludes (Just datadir)
676+ inc <- s5HeaderIncludes datadir
675677 return $ ("header-includes", inc) : variables
676678 else return variables
677679
678680 variables'' <- case mathMethod of
679681 LaTeXMathML Nothing -> do
680− s <- latexMathMLScript (Just datadir)
682+ s <- latexMathMLScript datadir
681683 return $ ("latexmathml-script", s) : variables'
682684 _ -> return variables'
683685
@@ -754,7 +756,7 @@ main = do
754756 let writerOutput = writer writerOptions doc' ++ "\n"
755757
756758 case writerName' of
757− "odt" -> saveOpenDocumentAsODT (Just datadir) outputFile sourceDirRelative referenceODT writerOutput
759+ "odt" -> saveOpenDocumentAsODT datadir outputFile sourceDirRelative referenceODT writerOutput
758760 _ -> if outputFile == "-"
759761 then putStr writerOutput
760762 else writeFile outputFile writerOutput