How can I get console input mid-build in Shake?

39 views Asked by At

For various unfortunate reasons, part of my build requires root privileges. I'm trying to use sudo for this:

cmd_ "sudo other_script.sh" [input] [output]

However, presumably because of how Shake handles console input/output, I cannot actually enter my password when sudo runs. I have tried passing WithStderr False to cmd_, as well as setting shakeLineBuffering=False, to no avail.

What is the correct way to allow a command to prompt for user input? If such a thing does not exist, is there another good way to do something similar?

1

There are 1 answers

0
Neil Mitchell On BEST ANSWER

The setting you are looking for is InheritStdin which ensures that the standard input is given to the process, so you can actually type in the password. You might also need to set EchoStderr or EchoStdout so you can see the password prompt.

Alternatively, you don't have to use cmd. Within Shake, cmd is optimised for an ergonomic way of running commands with tight integration. But it's easy enough to use the default System.Process module if you need more control, for example:

liftIO $ System.Process.system "sudo script input output"