File tree Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Original file line number Diff line number Diff line change 2525
2626target_go_version=" $1 "
2727
28- # Search for Dockerfiles in the current directory and its subdirectories
29- dockerfiles=$( find . -type f -name " *.Dockerfile" -o -name " Dockerfile" )
30-
31- # Check each Dockerfile
32- for file in $dockerfiles ; do
28+ # We find target files using the 'find' command in conjunction with the 'read'
29+ # command. We exclude some directories from the search.
30+ #
31+ # We use the 'read' command to help ensure that we correctly handle filenames
32+ # with spaces, newlines, and special characters. The '-print0' option in 'find'
33+ # outputs filenames separated by a null character. This allows the 'read'
34+ # command in the while loop to accurately distinguish each filename. The
35+ # 'target_files' array is then populated, preserving the integrity of each
36+ # filename. This approach ensures safe handling of filenames, regardless of
37+ # their complexity.
38+ while IFS= read -r -d ' ' file; do
39+ target_files+=(" $file " )
40+ done < <( find . \
41+ -path ./vendor -prune -o \
42+ -type f \
43+ \( -name " *.Dockerfile" -o -name " Dockerfile" \) \
44+ -print0 \
45+ )
46+
47+ # Check for the expected Go version in each file.
48+ for file in " ${target_files[@]} " ; do
3349 check_go_version " $file " " $target_go_version "
3450done
3551
52+
3653echo " All Dockerfiles pass the Go version check for Go version $target_go_version ."
Original file line number Diff line number Diff line change 3636
3737target_go_version=" $1 "
3838
39- # Search for YAML files in the current directory and its subdirectories
40- yaml_files=$( find . -type f -name " *.yaml" -o -name " *.yml" )
41-
42- # Check each YAML file
43- for file in $yaml_files ; do
39+ # We find target files using the 'find' command in conjunction with the 'read'
40+ # command. We exclude some directories from the search.
41+ #
42+ # We use the 'read' command to help ensure that we correctly handle filenames
43+ # with spaces, newlines, and special characters. The '-print0' option in 'find'
44+ # outputs filenames separated by a null character. This allows the 'read'
45+ # command in the while loop to accurately distinguish each filename. The
46+ # 'target_files' array is then populated, preserving the integrity of each
47+ # filename. This approach ensures safe handling of filenames, regardless of
48+ # their complexity.
49+ while IFS= read -r -d ' ' file; do
50+ target_files+=(" $file " )
51+ done < <( find . \
52+ -path ./vendor -prune -o \
53+ -type f \
54+ \( -name " *.yaml" -o -name " *.yml" \) \
55+ -print0 \
56+ )
57+
58+ # Check for the expected Go version in each file.
59+ for file in " ${target_files[@]} " ; do
4460 check_go_version " $file " " $target_go_version "
4561done
4662
You can’t perform that action at this time.
0 commit comments