Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fredrik Wieczerkowski
curry-libs
Commits
bbdf75d2
Commit
bbdf75d2
authored
Mar 10, 2015
by
Michael Hanus
Browse files
IOExts.evalCmd improved for arguments containing spaces @fixes #1268@
parent
020ecca1
Changes
1
Hide whitespace changes
Inline
Side-by-side
IOExts.curry.pakcs
View file @
bbdf75d2
...
...
@@ -16,10 +16,11 @@ module IOExts
, IORef, newIORef, readIORef, writeIORef, modifyIORef
) where
import System
import IO
import Char(isSpace)
import Directory(removeFile)
import IO
import Read(readNat)
import System
--- Executes a command with a new default shell process.
--- The standard I/O streams of the new process (stdin,stdout,stderr)
...
...
@@ -47,7 +48,8 @@ evalCmd :: String -> [String] -> String -> IO (Int, String, String)
evalCmd cmd args input = do
pid <- getPID
let tmpfile = "/tmp/PAKCS_evalCMD"++show pid
(hi,ho,he) <- execCmd (unwords (cmd:args) ++ " ; (echo $? > "++tmpfile++")")
(hi,ho,he) <- execCmd (unwords (map wrapArg (cmd:args)) ++
" ; (echo $? > "++tmpfile++")")
hPutStrLn hi input
hClose hi
outs <- hGetEOF ho
...
...
@@ -56,6 +58,8 @@ evalCmd cmd args input = do
removeFile tmpfile
return (readNat ecodes, outs, errs)
where
wrapArg s = if any isSpace s then '"':s++"\"" else s
--- Reads from an input handle until EOF and returns the input.
hGetEOF :: Handle -> IO String
hGetEOF h = do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment