Home > Enterprise >  How to allocate PTY using Shake?
How to allocate PTY using Shake?

Time:09-17

I'm trying to run a command interactively from my build script:

#!/usr/bin/env stack
{- stack
script
--resolver lts-18.8
--ghc-options -Wall
-}
import Development.Shake

main :: IO ()
main = shakeArgs shakeOptions $ do
  phony "cfg" $ do
    command_ [] "vim" []

But it does not work. I suppose I need to allocate a terminal to be able to run vim interactively. How can I do that?

CodePudding user response:

The Shake functions for running commands (command, cmd etc) are designed for batch commands that run without user interaction. While there are things you can do to make them more compatible with something like Vim (e.g. InheritStdin) there are probably aspects of Shake that will make things harder (e.g. capturing the stderr, which might result in a memory leak).

Happily, Shake can work just as well with the functions in System.Process, so instead of calling command you can write:

liftIO $ System.Process.createProcess $ System.Process.shell "vim"

The createProcess takes a record with many types of process-related settings, so can be customised to make Vim work.

  • Related