Skip to content

Normalize .sh scripts to LF endings - #105

Merged
madebygps merged 4 commits into
learntocloud:mainfrom
Human-Gechi:fix/normalize_ctf_setup.sh
Jun 10, 2026
Merged

Normalize .sh scripts to LF endings#105
madebygps merged 4 commits into
learntocloud:mainfrom
Human-Gechi:fix/normalize_ctf_setup.sh

Conversation

@Human-Gechi

@Human-Gechi Human-Gechi commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Normalize ctf_setup.sh to follow LF endings

This PR normalizes ctf_setup.sh to LF line endings and adds repo-level .gitattributes enforcement so shell scripts stay compatible across Windows, macOS, and Linux. The setup script also uses perl -pi -e 's/\r\n/\n/g' "$0" turning CRLF \r\n to \n LF to self-normalize its own line endings during execution.

What changed

  • Converted ctf_setup.sh and other affected .sh files to LF line endings.
  • Added .gitattributes rules to enforce LF for shell scripts
  • Renormalizing tracked *.sh files using git add --renormalize '**/*.sh' so the repository stores the corrected line endings going forward.

Closes #92

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

This PR addresses cross-platform shell compatibility by normalizing shell scripts to LF endings (fixing the CRLF parse failures described in #92) and attempting to enforce LF going forward via Git attributes.

Changes:

  • Normalized existing *.sh scripts (including CI test scripts) to LF line endings.
  • Added a Git attributes file intended to enforce eol=lf for *.sh files.
  • Added a self-normalization step to ctf_setup.sh to convert CRLF to LF at runtime.
Show a summary per file
File Description
ctf_setup.sh Adds runtime line-ending normalization and includes LF normalization.
.github/skills/ctf-testing/test_ctf_challenges.sh LF normalization (no intended logic change).
.github/skills/ctf-testing/deploy_and_test.sh LF normalization (no intended logic change).
.gitattribute Adds Git attributes rule intended to enforce LF for *.sh files (but filename is currently incorrect).

Copilot's findings

  • Files reviewed: 2/4 changed files
  • Comments generated: 2

Comment thread .gitattribute Outdated
Comment on lines +1 to +2
# Shell Scripts LF enforcement
*.sh text eol=lf No newline at end of file
Comment thread ctf_setup.sh
Comment on lines 6 to 10
set -euo pipefail

perl -pi -e 's/\r\n/\n/g' "$0"

exec > >(tee /var/log/ctf_setup.log) 2>&1

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.

Copilot's findings

  • Files reviewed: 2/4 changed files
  • Comments generated: 1

Comment thread ctf_setup.sh
Comment on lines 6 to 10
set -euo pipefail

perl -pi -e 's/\r\n/\n/g' "$0"

exec > >(tee /var/log/ctf_setup.log) 2>&1
@madebygps
madebygps self-requested a review June 8, 2026 20:30

@madebygps madebygps left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ShellCheck is still failing. Please review the errors. You should be able to view them by expaning the 'All Checks have failed', then select the 3 dots in the ShellCheck one and click view details.

@madebygps
madebygps merged commit 0cf54c2 into learntocloud:main Jun 10, 2026
1 check passed
@madebygps

Copy link
Copy Markdown
Collaborator

I resolved this

@Human-Gechi

Copy link
Copy Markdown
Contributor Author

What was the fix to the error @madebygps
I had no idea on how to implement the changes Copilot recommended asides using perl

@madebygps

Copy link
Copy Markdown
Collaborator

@Human-Gechi for future contributions, please let us know if something is blocking you, we are always happy to answer questions and guide.

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.

Normalize ctf_setup.sh to LF line endings so shell checks pass

3 participants