summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-06-30 14:03:47 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-06-30 14:03:47 -0700
commit264e366f1a973efa56fc32079927fc51cc1936ca (patch)
tree311b32f26a8dd7fb5ed63f8cc72c9e1835b39f8d
parent124cfb80f573209c829e29a74547c7a3cf6b9a6f (diff)
Filters: respect shebang if filter is executable.
Closes #1389.
-rw-r--r--pandoc.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 6281113cb..bf5f387dd 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -49,7 +49,7 @@ import System.Console.GetOpt
import Data.Char ( toLower )
import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort )
import System.Directory ( getAppUserDataDirectory, findExecutable,
- doesFileExist )
+ doesFileExist, Permissions(..), getPermissions )
import System.IO ( stdout, stderr )
import System.IO.Error ( isDoesNotExistError )
import qualified Control.Exception as E
@@ -104,8 +104,12 @@ externalFilter f args' d = do
Nothing -> do
exists <- doesFileExist f
if exists
- then return $
+ then do
+ isExecutable <- executable `fmap`
+ getPermissions f
+ return $
case map toLower $ takeExtension f of
+ _ | isExecutable -> (f, args')
".py" -> ("python", f:args')
".hs" -> ("runhaskell", f:args')
".pl" -> ("perl", f:args')