diff options
Diffstat (limited to 'src/extern')
-rw-r--r-- | src/extern/runproc.nim | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/extern/runproc.nim b/src/extern/runproc.nim index fa1ed9bc..6cad73a0 100644 --- a/src/extern/runproc.nim +++ b/src/extern/runproc.nim @@ -30,7 +30,7 @@ proc runProcess*(term: Terminal, cmd: string, wait = false): bool = term.restart() # Run process, and capture its output. -proc runProcessCapture*(term: Terminal, cmd: string, outs: var string): bool = +proc runProcessCapture*(cmd: string, outs: var string): bool = let file = popen(cmd, "r") if file == nil: return false @@ -40,3 +40,15 @@ proc runProcessCapture*(term: Terminal, cmd: string, outs: var string): bool = if rv == -1: return false return rv == 0 + +# Run process, and write an arbitrary string into its standard input. +proc runProcessInto*(cmd, ins: string): bool = + let file = popen(cmd, "w") + if file == nil: + return false + let fs = newFileStream(file) + fs.write(ins) + let rv = pclose(file) + if rv == -1: + return false + return rv == 0 |