2020# Standard color definitions
2121GREEN=" \033[32m"
2222RED=" \033[31m"
23- BLUE=" \033[94m"
24- BOLD=" \033[1m"
2523NORMAL=" \033[0m"
2624
2725info ()
@@ -122,8 +120,7 @@ run-shellcheck()
122120# Formatting
123121SUCCESS=true
124122
125- # Get list of shell scripts and .c/.h files for linting
126- ALL_C_FILES=$( git ls-files " :/*.c" " :/*.h" )
123+ # Get list of shell scripts for linting
127124SHELL_SCRIPTS=$( git grep -l ' ' :/ | xargs printf " '%s' " | xargs -L 1 shfmt -f)
128125
129126gh_group_start " Linting nix files with nixpkgs-fmt"
151148gh_group_end
152149
153150gh_group_start " Linting c files with clang-format"
154- checkerr " Lint C" " $( clang-format $( git ls-files " :/*.c" " :/*.h" ) --Werror --dry-run 2>&1 | grep " error:" | cut -d ' :' -f 1,2 | tr ' :' ' ' ) "
151+ lint-c-files ()
152+ {
153+ for file in $( git ls-files -- " :/*.c" " :/*.h" ) ; do
154+ # Ignore symlinks
155+ if [[ ! -L $file ]]; then
156+ clang-format --Werror --dry-run " $file " 2>&1 | grep " error:" | cut -d ' :' -f 1,2 | tr ' :' ' '
157+ fi
158+ done
159+ }
160+ checkerr " Lint C" " $( lint-c-files) "
155161gh_group_end
156162
157163check-eol-dry-run ()
@@ -173,22 +179,22 @@ check-spdx()
173179 local success=true
174180 for file in $( git ls-files -- " :/" " :/!:*.json" " :/!:*.png" " :/!:*LICENSE*" " :/!:.git*" " :/!:flake.lock" ) ; do
175181 # Ignore symlinks
176- if [[ ! -L $file && $( grep " SPDX-License-Identifier:" $file | wc -l) == 0 ]]; then
182+ if [[ ! -L $file && $( grep " SPDX-License-Identifier:" " $file " | wc -l) == 0 ]]; then
177183 gh_error " $file " " ${line:- 1} " " Missing license header error" " $file is missing SPDX License header"
178184 success=false
179185 fi
180186 done
181187 for file in $( git ls-files -- " *.[chsS]" " *.py" " *.mk" " *.yml" " **/Makefile*" " :/!proofs/cbmc/*.py" " :/!examples/bring_your_own_fips202/custom_fips202/tiny_sha3/*" " :/!examples/custom_backend/mldsa_native/src/fips202/native/custom/src/*" ) ; do
182188 # Ignore symlinks
183- if [[ ! -L $file && $( grep " Copyright (c) The mldsa-native project authors" $file | wc -l) == 0 ]]; then
189+ if [[ ! -L $file && $( grep " Copyright (c) The mldsa-native project authors" " $file " | wc -l) == 0 ]]; then
184190 gh_error " $file " " ${line:- 1} " " Missing copyright header error" " $file is missing copyright header"
185191 success=false
186192 fi
187193 done
188194 # For source files in dev/* and mldsa/*, we enforce `Apache-2.0 OR ISC OR MIT`
189195 for file in $( git ls-files -- " *.[chsSi]" | grep " ^dev/\|^mldsa/" ) ; do
190196 # Ignore symlinks
191- if [[ ! -L $file && $( grep " SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT" $file | wc -l) == 0 ]]; then
197+ if [[ ! -L $file && $( grep " SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT" " $file " | wc -l) == 0 ]]; then
192198 gh_error " $file " " ${line:- 1} " " Missing license header error" " $file is not licensed under 'Apache-2.0 OR ISC OR MIT'"
193199 success=false
194200 fi
@@ -209,7 +215,7 @@ gh_group_end
209215
210216check-autogenerated-files ()
211217{
212- if python3 $ROOT /scripts/autogen --dry-run; then
218+ if python3 " $ROOT " /scripts/autogen --dry-run; then
213219 info " Check native auto-generated files"
214220 gh_summary_success " Check native auto-generated files"
215221 else
@@ -225,7 +231,7 @@ gh_group_end
225231
226232check-magic ()
227233{
228- if python3 $ROOT /scripts/check-magic > /dev/null; then
234+ if python3 " $ROOT " /scripts/check-magic > /dev/null; then
229235 info " Check magic constants"
230236 gh_summary_success " Check magic constants"
231237 else
245251
246252check-contracts ()
247253{
248- if python3 $ROOT /scripts/check-contracts > /dev/null; then
254+ if python3 " $ROOT " /scripts/check-contracts > /dev/null; then
249255 info " Check contracts"
250256 gh_summary_success " Check contracts"
251257 else
0 commit comments