goncalotomas / cmd

Erlang `os:cmd` with option to get the return code instead of the output.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmd

hex version Build Status Dialyzer Enabled

An OTP library for when you want os:cmd but sometimes need to check return codes.

Build

$ 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

About

Erlang `os:cmd` with option to get the return code instead of the output.

License:Apache License 2.0


Languages

Language:Erlang 100.0%