Allow running bash shell commands
Current implementation of process library has limited usability. CreateProcess record stores CmdSpec field, which is either a RawCommand or ShellCommand. The problem is that:
-
RawCommandcommand quotes and escapes the command parameters -
ShellCommanddoes no escaping but it runs command inshshell
Corollary: there is no way to run bash command with unescaped parameters. As a result there is no way to run this command (and many others):
diff <(echo $ENV_FOO) <(echo $ENV_BAR)
Running it as a RawCommand (using proc function) fails because command line parameters are escaped and become incorrect. Running it as ShellCommand (using shell function) fails because this is not valid sh syntax. I propose to create function that allows user to run bash commands without escaping the parameters (or even better, run any shell the user wants). In other words this program:
import System.Exit
import System.Process
main :: IO ()
main = do
(_, _, _, pid) <- createProcess (SOME_NEW_FUNCTION "diff" ["<(echo $FOO)", "<(echo $BAR)"] )
{ env = Just [("FOO","Foo"),("BAR","Bar")] }
ecode <- waitForProcess pid
case ecode of
ExitSuccess -> putStrLn "All’s right with the world!"
ExitFailure _ -> putStrLn ":-("
should produce:
1c1
< Foo
---
> Bar
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.8.1-rc2 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/process |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |