Skip to content

chore: sync *.ps1 EOL fix from canonical#146

Merged
Chris-Wolfgang merged 1 commit into
mainfrom
chore/sync-ps1-eol-from-canonical
May 12, 2026
Merged

chore: sync *.ps1 EOL fix from canonical#146
Chris-Wolfgang merged 1 commit into
mainfrom
chore/sync-ps1-eol-from-canonical

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

Syncs the canonical *.ps1 EOL fix from repo-template#347 + #348. Removes the CRLF + UTF-8-BOM overrides for *.ps1 files in .gitattributes and .editorconfig.

Why

The #!/usr/bin/env pwsh shebang at the top of every script in scripts/ doesn't work as an executable on Linux/macOS when files are stored with CRLF + BOM:

  1. CRLF: kernel parses #!/usr/bin/env pwsh\r and tries to find an interpreter named pwsh\r — fails.
  2. BOM: bytes EF BB BF appear 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

File Before After
.gitattributes *.ps1 text eol=crlf *.ps1 text eol=lf
.editorconfig [*.ps1] end_of_line = crlf, charset = utf-8-bom (both removed; LF + utf-8 from [*] defaults)

Comments rewritten to explain the shebang rationale.

What does NOT change

  • Files in the index: already LF. The CRLF rule was aspirational policy that never matched reality. No file content rewrites in this PR.
  • Windows users: core.autocrlf=true (Git for Windows default) still gives CRLF in working tree on checkout. Only the index/wire format is LF.
  • Indent: still 4 spaces for *.ps1.

Note about the protected-files guard

This PR touches .gitattributes (in canonical the rule is in .editorconfig's domain too) and .editorconfig (protected). The Detect .NET Projects guard will fail it. Maintainer override required — same path as the canonical PRs.

Test plan

  • Maintainer override + merge
  • After merge, git ls-files --eol scripts/*.ps1 shows i/lf w/* attr/text eol=lf everywhere

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>
Copilot AI review requested due to automatic review settings May 10, 2026 00:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Syncs repository configuration to ensure *.ps1 scripts are stored with LF (and UTF-8 without BOM via global defaults) so PowerShell shebang scripts remain executable on Linux/macOS, aligning this repo with the canonical template change.

Changes:

  • Updates .gitattributes to store *.ps1 with eol=lf instead of eol=crlf.
  • Removes the end_of_line=crlf and charset=utf-8-bom overrides from .editorconfig’s [*.ps1] section, relying on global defaults.
  • Rewrites comments to document the shebang + BOM/CRLF rationale.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.gitattributes Switches *.ps1 attribute to eol=lf and updates rationale comments for cross-platform shebang execution.
.editorconfig Removes PowerShell-specific CRLF/BOM overrides so global lf + utf-8 defaults apply.

Comment thread .gitattributes
Comment on lines +12 to +19
# PowerShell scripts: LF line endings, no BOM. Required for the
# `#!/usr/bin/env pwsh` shebang to work on Linux/macOS — the kernel
# parses CR as part of the interpreter name (looking for `pwsh\r`),
# and a UTF-8 BOM before `#!` prevents shebang recognition entirely.
# 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.
*.ps1 text eol=lf
Comment thread .editorconfig
Comment on lines 28 to 35
# PowerShell files
# PowerShell uses CRLF to maintain compatibility with Windows and PowerShell conventions
# This overrides the global end_of_line = lf setting and aligns with .gitattributes line 14
# 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.
[*.ps1]
indent_size = 4
@Chris-Wolfgang Chris-Wolfgang merged commit f3c5328 into main May 12, 2026
11 of 12 checks passed
@Chris-Wolfgang Chris-Wolfgang deleted the chore/sync-ps1-eol-from-canonical branch May 12, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants