jgm/pandoc — Issue #339: markdown2pdf deletes "/tmp/pandoc" directory with user's files in it
Author: docekal
Created: 2011-11-10 13:42:46+00:00
State: open

**What steps will reproduce the problem?**

1. mkdir `/tmp/pandoc`
2. copy some files in that directory
3. run `markdown2pdf` (even without any parameters)
4. `/tmp/pandoc` is deleted and so are the files you copied there in step 2

**What is the expected output?**

I expect markdown2pdf to rather create a randomly-named new empty directory in /tmp, not to silently use and then nuke existing directory with files in it.

**What version of the product are you using? On what operating system?**

pandoc `1.8.2.1`
Compiled with citeproc support.
OS: Arch Linux

**Please provide any additional information below.**

Fortunately, I only lost a few test files, so no harm done. It's probably not a big issue, but using fixed paths for temporary files is generally not a good idea. Not only someone might actually use it to place some files which then get nuked, but it may also create issues if `markdown2pdf` is run simultaneously (by same or different users). On Linux, there is a nice command `mktemp -d` that creates a randomly-named empty directory suitable to place temporary files in it and then delete it. Or you can at least make a name based on username and PID of running `markdownpdf`, that should be random enough and also prevent any conflicts if run simultaneously by more users.