fix return value of os.writefile_ifnotequal()#2667
Draft
mercury233 wants to merge 4 commits intopremake:masterfrom
Draft
fix return value of os.writefile_ifnotequal()#2667mercury233 wants to merge 4 commits intopremake:masterfrom
mercury233 wants to merge 4 commits intopremake:masterfrom
Conversation
- Change the behavior back - Update the document
nickclark2016
requested changes
Apr 27, 2026
| ### Return Value ### | ||
|
|
||
| True if successful, otherwise nil and an error message. | ||
| `1` if successful, `0` if the string is identical to the current file contents, otherwise `-1` and an error message. |
Member
There was a problem hiding this comment.
Suggest changing this to be a table
Contributor
|
Please add unit tests to prevent future regressions |
mercury233
commented
Apr 28, 2026
| ### Return Value ### | ||
|
|
||
| True if successful, otherwise nil and an error message. | ||
| `1` if successful, `0` if the string is identical to the current file contents, otherwise `-1` and an error message. |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| `1` if successful, `0` if the string is identical to the current file contents, otherwise `-1` and an error message. | |
| The first return value: | |
| | Value | Explanation | | |
| |-------|------------------------------------------------------| | |
| | 1 | The string was written to the file | | |
| | 0 | The string is identical to the current file contents | | |
| | -1 | An error occurred | | |
| The second return value is an error message if the first return value is -1, otherwise nil. |
should it be like this?
Contributor
Author
|
Added tests, but I’m unsure whether they are appropriate, since the |
Contributor
If the test fails before your fix then it's appropriate 😄 You may have to capture the original function value before it's stubbed out. Such as what I did in test_lua_unicode.lua: local real_io_open = io.open
-- ...
function suite.loadfile_UnicodeFilename()
local p = tmpname()
p = p .. "_café.lua"
local f = assert(real_io_open(p, "w"))
-- ...
end |
jkriegshauser
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
How does this PR change Premake's behavior?
Before #2654 , os.writefile_ifnotequal() returns
1if successful,0if the string is identical to the current file contents, otherwise-1and an error message. #2654 seems to changed this behavior accidentally, return0on success too. This PR change the behavior back.Anything else we should know?
@jkriegshauser
Did you check all the boxes?
closes #XXXXin comment to auto-close issue when PR is merged)You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!