[erlang-bugs] Re: Bug in c:nc, R13B01
Ulf Wiger
ulf.wiger@REDACTED
Wed Sep 30 09:58:23 CEST 2009
Mazen Harake wrote:
> EErrr... element(2, ...) I meant :D
>
> /Mazen
...and I was just about to suggest that
{ok, Cwd} = file:get_cwd(),
Dir = proplists:get_value(outdir, Opts, Cwd),
would be even more readable. ;-)
This would also cover the case where get_cwd() returns
{error,Reason} (which can happen "in rare circumstances"
on Unix, according to the manual) - it covers it in the
sense that it fails in an understandable way, rather than
setting Dir to something unusable (a POSIX error such as
'eacces'), which would trigger a failure somewhere else.
"Make things as simple as possible, but not simpler."
(A Einstein)
BR,
Ulf W
>
> Mazen Harake wrote:
>> I would suggest to replace
>>
>> {ok, Cwd} = file:get_cwd(),
>> Dir = case lists:keyfind(outdir, 1, Opts) of
>> {outdir, Out} -> Out;
>> false -> Cwd
>> end,
>>
>> with:
>>
>> Dir = proplists:get_value(outdir, Opts, element(1, file:get_cwd())),
>> ...
>>
>> Easier to read imho.
>>
>> /Mazen
--
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com
More information about the erlang-bugs
mailing list