Euphoria
Ticket #823:
Segfault with bad build dir
-
Reported by
mattlewis
Nov 28, 2012
If the specified build-dir exists, but is a file instead of a directory, the translator crashes.
The best thing to do here might be to emit an error message and quit. I think using an existing directory is probably fine, however.
Details
1. Comment by mattlewis
Nov 28, 2012
See: hg:euphoria/rev/6630ae98fa71
changeset: 5886:6630ae98fa71 branch: 4.0 user: Matt Lewis date: Wed Nov 28 17:08:06 2012 -0500 files: docs/release/4.0.6.txt source/msgtext.e source/traninit.e description:
- emit error and exit when user specifies a file as a build directory
- fixes ticket 823
2. Comment by jimcbrown
Nov 28, 2012
I haven't tested this, so I'm probably missing something really obvious here. I couldn't figure out what that was though.
It just looked like that this line
if file_type( output_dir ) = FILETYPE_DIRECTORY then
should actually be
if file_type( output_dir ) != FILETYPE_DIRECTORY then
3. Comment by mattlewis
Nov 29, 2012
Derp. Should be:
if file_type( output_dir ) = FILETYPE_FILE then
4. Comment by mattlewis
Nov 29, 2012
See: hg:euphoria/rev/181a2d7fe088
changeset: 5889:181a2d7fe088 branch: 4.0 parent: 5886:6630ae98fa71 user: Matt Lewis date: Thu Nov 29 04:59:40 2012 -0500 files: source/traninit.e description:
- correct file type check
- fixes ticket 823
5. Comment by jimcbrown
Nov 29, 2012
What happens if someone passes in '*.*' as a directory name? or 'c:\w?ndows' ?
6. Comment by mattlewis
Nov 29, 2012
On Linux, if I pass *.*, then the shell expands that into files, and it attempts to translate something random. If I quote it, that's the build directory that's used. Ditto for question marks. I haven't tested on Windows.
Perhaps we should open another ticket for that sort of thing?
7. Comment by jimcbrown
Nov 29, 2012
Huh, ok. I thought file_type() couldn't tell the difference between a file and a directory if a question mark or asterisk was in the name (so passing a file named '*.*' might still cause a crash).
Of course, if the directory has a wildcard character as part of its name, we need to be able to support that.
8. Comment by mattlewis
Nov 29, 2012
You're right, it returns FILETYPE_UNDEFINED. So I suppose that doesn't quite work (though it covers the most reasonable cases). I only looked at the documentation, which didn't say anything about those special cases.
I suppose we could just check for FILETYPE_DIRECTORY and FILETYPE_NOT_FOUND and throw an error for any other result.
9. Comment by mattlewis
Nov 29, 2012
See: hg:euphoria/rev/9bdc97379692
changeset: 5891:9bdc97379692 branch: 4.0 parent: 5889:181a2d7fe088 user: Matt Lewis date: Thu Nov 29 09:28:10 2012 -0500 files: docs/e2c.txt include/std/filesys.e source/msgtext.e source/traninit.e description:
- better solution for bad -build-dir parameter
- improved documentation for filesys:file_type()
- added documentation for -build-dir option for translator
- ticket 823