lfe / lfe

Lisp Flavoured Erlang (LFE)
Apache License 2.0
2.31k stars 138 forks source link

lfec keeps non-files in file list args #109

Closed oubiwann closed 9 years ago

oubiwann commented 9 years ago

When running lfec with the output dir argument, I got these odd errors:

./-o.lfe:none: no such file or directory
<some path>.lfe:none: no such file or directory

When I debugged this in lfec, it turned out that when the file list is provided, the -o and <outputdir> are included in it.

I was going to mess with the pattern matching in the parse-opts function, but then it occurred to me that even with that, someone (or more likely someone's script) might still pass a file that didn't exist. As such, it seemed that a general filter might be a better approach (2 bids, one stone).

I'll submit the PR for this shortly.

rvirding commented 9 years ago

I wonder if we should really silently remove files like this. It might cause confusion as errors will not show up.

oubiwann commented 9 years ago

Hrm, I'm not sure what you mean ...

It's possible that people could have .erl, .ex, or .jxa files in one project. In general I'm pretty against removing files from someone's project ...

Side note: this patch was provided when I noticed that "-o" and "/output/path/" were being passed with the file args in lfec. If we don't use this patch to filter only .lfe files for lfec to compile, then we'll have to add a separate fix for making sure that options don't end up in the file args list ...

rvirding commented 9 years ago

I think one reason you were getting that problem is that you were mixing flags and files. The lfe and lfec commands follow bash/sh conventions here rather that erl conventions. This means that all the flags and their arguments must come first, and as soon it detects an arg which is not a flag then it treats everything after that as files.

So if you write lfec foo.lfe -o mybin then you will get this error. You need to write lfec -o mybin foo.lfe. Lfec only recognises a fixed set of flags and you can explicitly end the flag section with a -- and everything after that is a file. So you can do lfec -o mybin -- -any-file-name.lfe.

That is why I was wondering whether we need to remove files from the list of files to compile. I didn't mean actually delete the actual files, not even I am that strict. :-)

Lfe behaves in the same way but arguments after the flags are the script name and then arguments.

oubiwann commented 9 years ago

Oh, right. I discovered the ordering after that.

Thanks :-)

On Sun, Jan 25, 2015 at 10:56 AM, Robert Virding notifications@github.com wrote:

I think one reason you were getting that problem is that you were mixing flags and files. The lfe and lfec commands follow bash/sh conventions here rather that erl conventions. This means that all the flags and their arguments must come first, and as soon it detects an arg which is not a flag then it treats everything after that as files.

So if you write lfec foo.lfe -o mybin then you will get this error. You need to write lfec -o mybin foo.lfe. Lfec only recognises a fixed set of flags and you can explicitly end the flag section with a -- and everything after that is a file. So you can do lfec -o mybin -- -any-file-name.lfe.

Lfe behaves in the same way but arguments after the flags are the script name and then arguments.

— Reply to this email directly or view it on GitHub https://github.com/rvirding/lfe/issues/109#issuecomment-71380976.