exec
Exec
Basic Shell-like, async by default, command execution with no shell interpreter invocation.
Installation
Add the dependency to your shard.yml
:
dependencies:
exec:
github: j8r/exec.cr
Usage examples
Adding .wait
(API reference) allow to have sync execution.
Shell-like syntax. The command and its arguments are merged in a single String
.
output, error = Exec.run "echo hello", { |process| puts process.wait.success? } #=> true
puts output.to_s #=> hello
Most efficient syntax: command as String
and arguments as Array(String)
Exec.new "/bin/true", &.wait
Exec.new("/bin/ls", ["/tmp", "-l"]) {}
Arguments can also be a separated String
. This is bit more efficient than being merged in a single string with the command.
Exec.run("/bin/ls", "/tmp -l")
License
Copyright (c) 2017-2019 Julien Reichardt - ISC License