on master help sign in
Fix unixFilter on Windows

On windows, the 'unixFilter' function used window's 'createProcess' function to create the external process that will filter some String input. The problem with this is that it is unable to execute batch stubs (eg. anything created using 'gem install ...') even if its in $PATH. Anyways a solution to this issue is to execute the batch file explicitly using 'cmd /c batchfile' but there is no rational way to know where said batchfile is on the system. My solution is to detect windows using the System.Info module and then instead of using 'proc' to create the function, use 'shell' instead which will be able to execute everything 'proc' can + batch files. Inspired by: http://www.blaenkdenum.com/posts/the-switch-to-hakyll/#scss Signed-off-by: Collin J. Doering <rekahsoft@gmail.com>

commitda7ae99b122280849e57fc695bdc67b4433d76b3 authorCollin J. Doering <rekahsoft@gmail.com> dateSun 23 Mar 2014, 17:30 (13 years ago) parent677a7f0
1 file changed+6−2
src/Hakyll/Core/UnixFilter.hs+6−2
src/Hakyll/Core/UnixFilter.hs+6−2
@@ -19,7 +19,7 @@ import System.Exit (ExitCode (..))
1919import System.IO (Handle, hClose, hFlush, hGetContents,
2020 hPutStr, hSetEncoding, localeEncoding)
2121import System.Process
22−
22+import System.Info
2323
2424--------------------------------------------------------------------------------
2525import Hakyll.Core.Compiler
@@ -105,8 +105,12 @@ unixFilterIO :: Monoid o
105105 -> i
106106 -> IO (o, String, ExitCode)
107107unixFilterIO writer reader programName args input = do
108+ let pr = if os == "mingw32"
109+ then shell $ unwords (programName : args)
110+ else proc programName args
111+
108112 (Just inh, Just outh, Just errh, pid) <-
109− createProcess (proc programName args)
113+ createProcess pr
110114 { std_in = CreatePipe
111115 , std_out = CreatePipe
112116 , std_err = CreatePipe