-
Notifications
You must be signed in to change notification settings - Fork 822
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
Incorrect return code from "rename()" syscall on a non-existing file #5505
Comments
Any plan for this ? When can we get this fixed ? |
@therealkenc , has it been fixed ? or still pending ?? Any update after three months ?? |
Any update ?? After 5 month. |
Any update ?? After 7 month. |
Seems fixed (since unknown version) ? Testing on 21H2:
|
@namniav , very strange, I have exactly the same windows version as yours, but it still happen: |
@skywind3000, oh, there must be something really weird... |
@liam-keepmove there is a work-around, install |
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request. Thank you! |
Environment
Steps to reproduce
test_rename.c
with the content:output:
Expected behavior
In a real linux, for example:
The program should output:
Because
rename()
on a non-existing file should return -1 and seterrno
toENOENT
.Actual behavior
WSL's
rename()
always returns0
if source file name equals to the dest file name no matter the file exists or not. This happens in the recently updates on windows 2004, the previous WSL in windows 1909 behaves correctly.Summary
rename()
should always return -1 and setENOENT
toerrno
if the file doesn't exist. This incorrect return code will break applications which rely on the rename return code:I am the maintainer of a command productivity tool z.lua, an issue related to WSL 1 has been reported recently: skywind3000/z.lua#104
Lua is lack of system APIs to detect file existence, a portable way for this is using
rename
:This is a widely used method to detect file existence in lua, it is also mentioned in stackoverflow.
While the latest WSL1's
rename()
system call always returns zero and break this function, which breaks z.lua in WSL1.The text was updated successfully, but these errors were encountered: