[erlang-bugs] Re: Bug in c:nc, R13B01

Mazen Harake mazen.harake@REDACTED
Wed Sep 30 08:43:03 CEST 2009


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


Alex Suraci wrote:
> Potential fix?: http://paste.pocoo.org/show/142193/
>
> I'll submit a patch but I'd prefer having some input as this is kind of
> a low-level part of Erlang (being in the stdlib and all).
>
> Description of changes: if an outdir is specified, Fname should be prefixed
> with that, otherwise it should be the cwd, as that's where compile:file will
> put the .beam file.
>
> - Alex
>
> On Sun, Sep 20, 2009 at 6:33 PM, Alex Suraci <i.am@REDACTED> wrote:
>   
>> Excerpt from lib/stdlib/src/c.erl: http://paste.pocoo.org/show/140752/
>>
>> On line 7, Fname is naively assumed to be a .beam file compiled
>> to the same directory where the source .erl file resided. However, this
>> is often false, for example when there is an `outdir' option, or when
>> calling `nc()' from the shell with a path to a file like "foo/bar" (in which
>> case compile:file just plops it in the cwd of the shell).
>>
>> For example. when you call `make:all([netload])' and your Emakefile
>> specifies `ebin' as your outdir, it will call `c:nc' and it'll compile fine,
>> but the modules won't update and you'll have no idea why (until you
>> dig a little deeper).
>>
>> So, really, the only way for this function to work properly is when
>> compiling with the shell's cwd being the same directory as the .erl file.
>>
>> --
>> Alex
>>
>>     
>
>
>
>   



More information about the erlang-bugs mailing list