-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
fs.writeFile() removes execute permissions from file #9380
Comments
You've a lot of moving parts here:
Can you repro it in a simpler setup? Default for writeFileSync is to truncate target file with
|
Interestingly the following has the desired behavior and preserves the executable flag:
You'd think the default 'w' would do just that, but it doesn't. Can we find out if that's due to the Windows to OS X translation layer or node? |
From Lines 30 to 52 in 40366df
'w' maps to O_TRUNC | O_CREAT | O_WRONLY , 'r+' to O_RDWR , what that maps to on Windows can be seen at Lines 403 to 453 in 40366df
CreateFile() to know.
That |
'w' preserves at least some metadata (archive/compress/index flags, permissions) when running on Windows against a local NTFS filesystem. That suggests CREATE_ALWAYS might be the right choice and the translation to OS X is at fault, but I'm not an expert in this area. |
cc @nodejs/fs |
IMHO mapping |
Setup:
executable.sh
on Mac with +x bitsScript:
=> the file has lost its executable bit
If you change to pass in a
r+
flag like so:the executable bits are kept.
Now maybe someone can enlighten me here why
fs.writeFile
by default does not user+
if it is better at keeping executable bits.The text was updated successfully, but these errors were encountered: