Keep shell installer line endings portable#24
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request configures gitattributes to enforce LF line endings for shell scripts and adds a test to verify that the installer script does not contain CRLF line endings. The reviewer suggests strengthening the test assertion to check for any carriage return character (\r) instead of just \r\n to ensure complete portability.
| it('keeps shell installers LF-only so bash can parse them on every OS', () => { | ||
| const installer = readFileSync(join(root, 'scripts', 'install.sh'), 'utf8') | ||
|
|
||
| assert.doesNotMatch(installer, /\r\n/) |
There was a problem hiding this comment.
To ensure complete portability and prevent any carriage return characters from causing syntax errors in Bash, it is safer to assert the absence of any carriage return (\r) rather than specifically the CRLF sequence (\r\n). A lone \r can also cause issues in Unix environments.
Suggested change
| assert.doesNotMatch(installer, /\r\n/) | |
| assert.doesNotMatch(installer, /\r/) |
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.
Summary
install.shcannot drift back to CRLF and break Bash parsing on macOS/Linux or Windows Bash environments.Validation