chore: sync *.ps1 EOL fix from canonical#19
Merged
Conversation
Removes the CRLF + UTF-8-BOM overrides for *.ps1 files in .gitattributes and .editorconfig. Required for the '#!/usr/bin/env pwsh' shebang at the top of every script in scripts/ to work as an executable on Linux/macOS. No file content rewrites — index has been LF the whole time. Only attr declarations align with reality now. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Aligns repository PowerShell script line-ending policy with the canonical template fix so PowerShell scripts can be executed via #!/usr/bin/env pwsh on Linux/macOS (avoiding CRLF and UTF-8 BOM shebang breakage).
Changes:
- Update
.gitattributesto enforce LF for*.ps1and rewrite rationale comments around shebang compatibility. - Remove
end_of_line = crlfandcharset = utf-8-bomoverrides for*.ps1from.editorconfig, relying on global defaults.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.gitattributes |
Switches *.ps1 to eol=lf and updates explanatory comments for shebang compatibility. |
.editorconfig |
Removes PowerShell-specific CRLF/BOM settings and updates comment guidance to reflect global defaults. |
Comment on lines
+16
to
+18
| # Modern PowerShell 7+ handles LF on Windows transparently; Git's | ||
| # autocrlf still gives Windows users CRLF in their working tree if | ||
| # desired without forcing CRLF into the index. |
Comment on lines
+29
to
+33
| # Only the indent override is needed; LF + UTF-8 (no BOM) come from the | ||
| # global [*] section above. LF + no-BOM is required for the | ||
| # `#!/usr/bin/env pwsh` shebang at the top of every script in scripts/ | ||
| # to work on Linux/macOS — CR breaks the kernel's exec lookup, and a | ||
| # leading BOM prevents shebang recognition entirely. |
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
Syncs the canonical
*.ps1EOL fix from repo-template#347 + #348. Removes the CRLF + UTF-8-BOM overrides for*.ps1files in.gitattributesand.editorconfig.Why
The
#!/usr/bin/env pwshshebang at the top of every script inscripts/doesn't work as an executable on Linux/macOS when files are stored with CRLF + BOM:#!/usr/bin/env pwsh\rand tries to find an interpreter namedpwsh\r— fails.EF BB BFappear before#!, so the kernel doesn't recognize the file as a shebang script at all.The original "PowerShell uses CRLF for Windows compatibility" rationale predates PowerShell 7+ (cross-platform). The PowerShell team's own canonical repos (
PowerShell/PowerShell,PSScriptAnalyzer) all use LF + no BOM.Changes
.gitattributes*.ps1 text eol=crlf*.ps1 text eol=lf.editorconfig [*.ps1]end_of_line = crlf,charset = utf-8-bom[*]defaults)Comments rewritten to explain the shebang rationale.
What does NOT change
core.autocrlf=true(Git for Windows default) still gives CRLF in working tree on checkout. Only the index/wire format is LF.*.ps1.Note about the protected-files guard
This PR touches
.gitattributes(in canonical the rule is in.editorconfig's domain too) and.editorconfig(protected). TheDetect .NET Projectsguard will fail it. Maintainer override required — same path as the canonical PRs.Test plan
git ls-files --eol scripts/*.ps1showsi/lf w/* attr/text eol=lfeverywhere