Skip to content

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

Merged
Chris-Wolfgang merged 2 commits into
mainfrom
chore/sync-ps1-eol-from-canonical
May 14, 2026
Merged

chore: sync *.ps1 EOL fix from canonical#30
Chris-Wolfgang merged 2 commits 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.

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)

What does NOT change

Files in the index were already LF. No file content rewrites.

Note about the protected-files guard

Touches .editorconfig (protected). Maintainer override required.

Test plan

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

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.

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:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Syncs the repository template’s PowerShell line-ending policy to ensure #!/usr/bin/env pwsh shebang-based execution works correctly on Linux/macOS by avoiding CRLF and UTF-8 BOM in *.ps1 files.

Changes:

  • Update .gitattributes to enforce LF for *.ps1 and document the shebang/CRLF/BOM rationale.
  • Remove end_of_line = crlf and charset = utf-8-bom overrides for *.ps1 in .editorconfig, relying on global defaults.

Reviewed changes

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

File Description
.gitattributes Switch *.ps1 to eol=lf and update inline documentation explaining shebang compatibility requirements.
.editorconfig Drop *.ps1 CRLF/BOM overrides so PowerShell scripts inherit LF + UTF-8 (no BOM) from global settings.

Comment thread .gitattributes Outdated
- .editorconfig: drop the [*.ps1] section entirely. Its only rule
  (indent_size = 4) was a no-op since the global [*] section already
  sets indent_size = 4. The shebang-rationale comment now sits as a
  top-level note explaining why no override is needed, and is honest
  that the shebang is only present 'where present' rather than in
  'every script in scripts/'.
- .gitattributes: tighten the *.ps1 comment so it doesn't imply that
  `eol=lf` prevents a BOM. Git attributes can only normalize line
  endings; BOM avoidance is enforced via .editorconfig's charset
  setting. Also clarify that `* text=auto eol=lf` (top of file)
  takes precedence over core.autocrlf, so the previous claim about
  Windows users getting CRLF in their working tree was inaccurate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Chris-Wolfgang Chris-Wolfgang merged commit dadd877 into main May 14, 2026
6 of 7 checks passed
@Chris-Wolfgang Chris-Wolfgang deleted the chore/sync-ps1-eol-from-canonical branch May 14, 2026 01:44
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