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,9 @@ run-shellcheck()
122120# Formatting
123121SUCCESS=true
124122
125- # Get list of shell scripts for linting
123+ # Get list of shell scripts and .c/.h files for linting
126124ALL_FILES=$( git grep -l ' ' :/)
125+ ALL_C_FILES=$( git ls-files " :/*.c" " :/*.h" )
127126SHELL_SCRIPTS=$( echo " $ALL_FILES " | xargs shfmt -f)
128127
129128gh_group_start " Linting nix files with nixpkgs-fmt"
151150gh_group_end
152151
153152gh_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 ' :' ' ' ) "
153+ checkerr " Lint C" " $( echo $ALL_C_FILES | xargs clang-format --Werror --dry-run 2>&1 | grep " error:" | cut -d ' :' -f 1,2 | tr ' :' ' ' ) "
155154gh_group_end
156155
157156check-eol-dry-run ()
@@ -173,22 +172,22 @@ check-spdx()
173172 local success=true
174173 for file in $( git ls-files -- " :/" " :/!:*.json" " :/!:*.png" " :/!:*LICENSE*" " :/!:.git*" " :/!:flake.lock" ) ; do
175174 # Ignore symlinks
176- if [[ ! -L $file && $( grep " SPDX-License-Identifier:" $file | wc -l) == 0 ]]; then
175+ if [[ ! -L $file && $( grep " SPDX-License-Identifier:" " $file " | wc -l) == 0 ]]; then
177176 gh_error " $file " " ${line:- 1} " " Missing license header error" " $file is missing SPDX License header"
178177 success=false
179178 fi
180179 done
181180 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
182181 # Ignore symlinks
183- if [[ ! -L $file && $( grep " Copyright (c) The mldsa-native project authors" $file | wc -l) == 0 ]]; then
182+ if [[ ! -L $file && $( grep " Copyright (c) The mldsa-native project authors" " $file " | wc -l) == 0 ]]; then
184183 gh_error " $file " " ${line:- 1} " " Missing copyright header error" " $file is missing copyright header"
185184 success=false
186185 fi
187186 done
188187 # For source files in dev/* and mldsa/*, we enforce `Apache-2.0 OR ISC OR MIT`
189188 for file in $( git ls-files -- " *.[chsSi]" | grep " ^dev/\|^mldsa/" ) ; do
190189 # Ignore symlinks
191- if [[ ! -L $file && $( grep " SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT" $file | wc -l) == 0 ]]; then
190+ if [[ ! -L $file && $( grep " SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT" " $file " | wc -l) == 0 ]]; then
192191 gh_error " $file " " ${line:- 1} " " Missing license header error" " $file is not licensed under 'Apache-2.0 OR ISC OR MIT'"
193192 success=false
194193 fi
@@ -209,7 +208,7 @@ gh_group_end
209208
210209check-autogenerated-files ()
211210{
212- if python3 $ROOT /scripts/autogen --dry-run; then
211+ if python3 " $ROOT " /scripts/autogen --dry-run; then
213212 info " Check native auto-generated files"
214213 gh_summary_success " Check native auto-generated files"
215214 else
@@ -225,7 +224,7 @@ gh_group_end
225224
226225check-magic ()
227226{
228- if python3 $ROOT /scripts/check-magic > /dev/null; then
227+ if python3 " $ROOT " /scripts/check-magic > /dev/null; then
229228 info " Check magic constants"
230229 gh_summary_success " Check magic constants"
231230 else
245244
246245check-contracts ()
247246{
248- if python3 $ROOT /scripts/check-contracts > /dev/null; then
247+ if python3 " $ROOT " /scripts/check-contracts > /dev/null; then
249248 info " Check contracts"
250249 gh_summary_success " Check contracts"
251250 else
0 commit comments