File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Check Line Endings
1+ name : Check Shell Script Line Endings
22
33on :
4- pull_request :
5- paths :
6- - ' **/*.sh'
74 push :
8- paths :
9- - ' **/*.sh'
5+ pull_request :
106
117jobs :
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
You can’t perform that action at this time.
0 commit comments