[erlang-questions] os:cmd/1 with return code

Richard Carlsson <>
Sat Oct 18 17:38:57 CEST 2008


BJörn Lindqvist wrote:
> 2008/10/18 Tim Fletcher <>:
>>> I've been trying to implement and os:cmd/1 variant that also returns
>>> the status code of the executed command. But it proved to be
>>> exceedingly difficult.
>> There's an example of that in eunit:
>>
>>  http://svn.process-one.net/contribs/trunk/eunit/src/eunit_lib.erl
> 
> That function does not run the command in a shell. So, for example,
> eunit_lib:command("exit 123") will not work.

_Should_ it run in a shell? I didn't find it obvious what a command
that "runs an operating system command" ought to do. If someone can
lay down the law here, I'd be grateful. I mean, it can obviously be
handy to be able to execute any shell command directly, but I guessed
that it might also be _not_ what one always wants. And of course, the
code must check then which platform it is on, so it can run the right
shell (for some definition of right).

    /Richard


-- 
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham



More information about the erlang-questions mailing list