Orc/discount — pull request #109 by chuckhoupt (2014-07-31 02:13:57+00:00)
Title: Adjust theme to allow output to stdout (-o /dev/stdout)

When the `theme` command is given the output option `-o /dev/stdout`, an error is raised because freopen() can't reopen stdout again. This pull-request fixes the issue by testing the output path for inode-identity before re-opening. A less complex alternative would be to adopt the hash convention `-o -` to signify standard output.

Having `theme` output to standard-out is particularly useful for simple CGI scripts. For example, with the fix, the following CGI script can be used to serve rendered markdown files. Without the fix, a temporary file must be created (and deleted) to capture the output.

```
#!/bin/sh
echo "Content-type: text/html"
echo
cd $(dirname "$PATH_TRANSLATED")
theme -o /dev/stdout "$PATH_TRANSLATED"
```