In --version, trap error in getAppUserDataDirectory.

This fixes a crash with `pandoc --version` on unusual systems with
no real user (e.g. SQL Server 2016).  Closes #3241.
This commit is contained in:
John MacFarlane 2016-11-18 11:25:13 +01:00
parent 99287f4754
commit 20b2269fb7

View file

@ -975,7 +975,10 @@ options =
(NoArg
(\_ -> do
prg <- getProgName
defaultDatadir <- getAppUserDataDirectory "pandoc"
defaultDatadir <- E.catch
(getAppUserDataDirectory "pandoc")
(\e -> let _ = (e :: E.SomeException)
in return "")
UTF8.hPutStrLn stdout (prg ++ " " ++ pandocVersion ++
compileInfo ++ "\nDefault user data directory: " ++
defaultDatadir ++ copyrightMessage)