aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-02-21 16:47:24 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-02-21 16:47:24 +0000
commit40ea955e23a684173f8f390d2e63980d7727d71c (patch)
tree1293f58f18f4100d65e6016bebcea2b257ed6d98
parentf9c690849e0e19562561d7810f90252c398f15de (diff)
downloadpandoc-40ea955e23a684173f8f390d2e63980d7727d71c.tar.gz
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
-rw-r--r--src/pandoc.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 9b05f054c..659b091c8 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -58,7 +58,7 @@ import System.IO.UTF8
import Text.CSL
import Text.Pandoc.Biblio
#endif
-import Control.Monad (when, unless)
+import Control.Monad (when, unless, liftM)
import Network.HTTP
import Network.URI (parseURI)
import Data.ByteString.Lazy.UTF8 (toString)
@@ -633,8 +633,10 @@ main = do
let sources = if ignoreArgs then [] else args
datadir <- case mbDataDir of
- Just d -> return d
- Nothing -> getAppUserDataDirectory "pandoc"
+ Nothing -> catch
+ (liftM Just $ getAppUserDataDirectory "pandoc")
+ (const $ return Nothing)
+ Just _ -> return mbDataDir
-- assign reader and writer based on options and filenames
let readerName' = if null readerName
@@ -653,7 +655,7 @@ main = do
Just r -> return r
Nothing -> error ("Unknown writer: " ++ writerName')
- templ <- getDefaultTemplate (Just datadir) writerName'
+ templ <- getDefaultTemplate datadir writerName'
let defaultTemplate = case templ of
Right t -> t
Left e -> error (show e)
@@ -671,13 +673,13 @@ main = do
variables' <- if writerName' == "s5" && standalone'
then do
- inc <- s5HeaderIncludes (Just datadir)
+ inc <- s5HeaderIncludes datadir
return $ ("header-includes", inc) : variables
else return variables
variables'' <- case mathMethod of
LaTeXMathML Nothing -> do
- s <- latexMathMLScript (Just datadir)
+ s <- latexMathMLScript datadir
return $ ("latexmathml-script", s) : variables'
_ -> return variables'
@@ -754,7 +756,7 @@ main = do
let writerOutput = writer writerOptions doc' ++ "\n"
case writerName' of
- "odt" -> saveOpenDocumentAsODT (Just datadir) outputFile sourceDirRelative referenceODT writerOutput
+ "odt" -> saveOpenDocumentAsODT datadir outputFile sourceDirRelative referenceODT writerOutput
_ -> if outputFile == "-"
then putStr writerOutput
else writeFile outputFile writerOutput