-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Opening nonexisting file in append mode #26
Comments
The relevant documentation is not "man 2 open", but rather the IO manual, which says this about the mode parameter to To me, this says that the answer to your question is "yes, this is intentional". Of course one may now discuss whether the intent was justified or not ;-). And if we decide it is not, could change things. But before making a change there, I think it's vital to consider ramifications and alternatives, lest this breaks some existing code out there relying on the current behavior... As to alternatives: IO_File is just a simple wrapper around IO_open + IO_WrapFD. So you could write a function doing what you want yourself, something like this (untested): CreateAndAppend := function(filename)
local fd;
fd := IO_open(filename,IO.O_CREAT+IO.O_APPEND+IO.O_WRONLY,0);
if fd = fail then return fail; fi;
return IO_WrapFD(fd,false,IO.DefaultBufSize);
end As to |
Just one minor comment, by design all of gz, bz2 and xz support concatenating different compressed files together and work fine, exactly to support this kind of thing, so having the same functionality on compressed files seem the same. I would prefer not setting files world-writable by default however, undergraduate students have access to my home directory at uni, I wouldn't want them writing to files I accidentally left world-writable there! |
For the moment just concentrating on the issue critical for me. What would be the potential problem with create and append? This seems to be the right behaviour to me, thinking that in the shell I thought about writing something like I started with the IO manual, but the quoted sentence does not say anything about the behaviour of mode "a", probably we parse natural language differently :). Yes, I don't want to break existing code, but I''m also resistant to put glue into downstream code while there seems to be a clean solution upstream. |
By the way, having thought about this a little more, I think I tend toward the change. This is because "r", "w" and "a" are (in my mind) typically associated with fopen, and in fopen "a" creates a new file if none exists. |
I also had the same behaviour in my mind. Then for the second problem of the permissions, would removing world access for appned be sufficient? How about world access for "w"? |
Based on your earlier comments, seeing as the permissions are exactly the same as IO's permissions for "w", we should (in this patch at least in my opinion) leave them alone. We could consider, in a separate issue, if it is worth breaking backwards compatibility to lower the default permissions. |
Is this the right behaviour?
Checked documentation (up to man 2 open), but no clear answer.
The text was updated successfully, but these errors were encountered: