Skip to content

Conversation

@HammerGS
Copy link
Member

  • Add fixScriptLineEndings task to convert CRLF to LF in generated scripts
  • Add filter to distribution copy of shell.sh to strip CR characters
  • Scripts generated by CreateStartScripts on Windows now work on Unix

When built on Windows, Gradle's CreateStartScripts generates scripts with CRLF line endings which fail on Unix systems with 'bad interpreter' errors. This fix ensures all shell scripts have Unix-compatible LF line endings.

- Add fixScriptLineEndings task to convert CRLF to LF in generated scripts
- Add filter to distribution copy of shell.sh to strip CR characters
- Scripts generated by CreateStartScripts on Windows now work on Unix

When built on Windows, Gradle's CreateStartScripts generates scripts with
CRLF line endings which fail on Unix systems with 'bad interpreter' errors.
This fix ensures all shell scripts have Unix-compatible LF line endings.
Copilot AI review requested due to automatic review settings January 30, 2026 04:30
@HammerGS HammerGS requested a review from a team as a code owner January 30, 2026 04:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes shell script line ending issues that occur when building on Windows. It adds a new Gradle task to convert CRLF line endings to LF in generated start scripts and applies a filter to ensure the shell.sh script has Unix-compatible line endings when copied to the distribution.

Changes:

  • Added fixScriptLineEndings task to convert CRLF to LF in scripts generated by CreateStartScripts
  • Added filter to strip CR characters from shell.sh during distribution copy
  • Added fixScriptLineEndings as a dependency to packagePrepWork task

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


tasks.register('fixScriptLineEndings') {
description = 'Convert CRLF to LF in shell scripts for Unix compatibility.'
dependsOn createStartScripts
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The fixScriptLineEndings task depends only on createStartScripts but references startScripts.outputDir on line 276. Since both the startScripts task (from the application plugin) and createStartScripts task write to the same output directory, this task should also declare a dependency on startScripts to ensure proper task ordering and that all scripts are present before line ending conversion occurs.

Suggested change
dependsOn createStartScripts
dependsOn createStartScripts
dependsOn startScripts

Copilot uses AI. Check for mistakes.
Comment on lines +272 to +280
description = 'Convert CRLF to LF in shell scripts for Unix compatibility.'
dependsOn createStartScripts
doLast {
// Fix scripts generated by createStartScripts
fileTree(startScripts.outputDir).each { file ->
if (!file.name.endsWith('.bat')) {
def content = file.text
if (content.contains('\r\n')) {
file.text = content.replaceAll('\r\n', '\n')
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The line ending detection and replacement logic may not handle all cases correctly. The check on line 279 only detects CRLF sequences ('\r\n'), which means files with standalone CR characters ('\r') or mixed line endings won't be detected. Similarly, the replacement on line 280 only replaces CRLF with LF, leaving any standalone CR characters unchanged. Consider using a more comprehensive approach such as replacing all CR characters with file.text = content.replaceAll('\r', '') which will handle both CRLF (by removing the CR, leaving the LF) and standalone CR cases.

Suggested change
description = 'Convert CRLF to LF in shell scripts for Unix compatibility.'
dependsOn createStartScripts
doLast {
// Fix scripts generated by createStartScripts
fileTree(startScripts.outputDir).each { file ->
if (!file.name.endsWith('.bat')) {
def content = file.text
if (content.contains('\r\n')) {
file.text = content.replaceAll('\r\n', '\n')
description = 'Convert CRLF and CR line endings to LF in shell scripts for Unix compatibility.'
dependsOn createStartScripts
doLast {
// Fix scripts generated by createStartScripts
fileTree(startScripts.outputDir).each { file ->
if (!file.name.endsWith('.bat')) {
def content = file.text
if (content.contains('\r')) {
file.text = content.replaceAll('\r', '')

Copilot uses AI. Check for mistakes.
@HammerGS HammerGS marked this pull request as draft January 30, 2026 04:40
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