An OTP library for when you want os:cmd
but sometimes need to check return codes.
$ rebar3 compile
Try it out
$ 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