README.md
# cmd
[](https://hex.pm/packages/cmd)
[](https://travis-ci.org/goncalotomas/cmd)

An OTP library for when you want `os:cmd` but sometimes need to check return codes.
Build
-----
$ rebar3 compile
Try it out
```erl-sh
$ rebar3 shell
===> Verifying dependencies...
===> Compiling cmd
Erlang/OTP 21 [erts-10.0.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
Eshell V10.0.6 (abort with ^G)
1> cmd:run("echo hi").
"hi\n"
2> cmd:run("echo hi", return_code).
0
3> cmd:run("cp / # this is an invalid command").
"usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file\n cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory\n"
4> cmd:run("cp / # this is an invalid command", return_code).
64
```