Skip to content

Commit a086c2a

Browse files
author
Jakub Marciniak
committed
version 3
1 parent 4ad5e25 commit a086c2a

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
1-
name: Check Line Endings
1+
name: Check Shell Script Line Endings
22

33
on:
4-
pull_request:
5-
paths:
6-
- '**/*.sh'
74
push:
8-
paths:
9-
- '**/*.sh'
5+
pull_request:
106

117
jobs:
12-
check_line_endings:
8+
check_crlf_in_sh:
9+
name: Check for CRLF in .sh files
1310
runs-on: ubuntu-latest
1411
steps:
1512
- name: Checkout code
1613
uses: actions/checkout@v3
14+
with:
15+
unix-newlines: false
1716

18-
- name: Find shell scripts with CRLF line endings
17+
- name: Scan all *.sh files for CRLF endings
1918
shell: bash
2019
run: |
21-
echo "🔍 Checking for CRLF endings in shell scripts..."
20+
echo "🔍 Scanning all *.sh files for CRLF endings..."
2221
23-
# Szukamy plików .sh zawierających CRLF
24-
mapfile -t crlf_files < <(find . -type f -name "*.sh" -exec grep -Il $'\r' {} +)
22+
mapfile -t all_sh_files < <(find . -type f -name "*.sh")
2523
26-
if (( ${#crlf_files[@]} > 0 )); then
27-
echo ""
28-
echo "🚫 The following .sh files contain CRLF (Windows-style) line endings:"
29-
for file in "${crlf_files[@]}"; do
30-
echo " • $file"
24+
bad_files=()
25+
26+
for file in "${all_sh_files[@]}"; do
27+
if grep -q $'\r' "$file"; then
28+
bad_files+=("$file")
29+
fi
30+
done
31+
32+
if (( ${#bad_files[@]} > 0 )); then
33+
echo "🚫 Found ${#bad_files[@]} shell script(s) with CRLF endings:"
34+
for f in "${bad_files[@]}"; do
35+
echo " • $f"
3136
done
3237
echo ""
33-
echo "💡 Please convert them to LF endings using 'dos2unix' or 'shellman line_endings'."
38+
echo "💡 Please convert these files to LF using 'dos2unix <file>' or 'shellman line_endings --file <file> --to lf'"
3439
exit 1
3540
else
36-
echo "✅ All .sh files use correct LF line endings."
41+
echo "✅ All .sh files use proper LF line endings."
3742
fi

0 commit comments

Comments
 (0)