refactor(scripts): clean up bash scripts

This commit is contained in:
ObserverOfTime 2024-03-28 17:33:55 +02:00
parent 3950dddfde
commit f50123a3ec
18 changed files with 241 additions and 261 deletions

View file

@ -1,20 +1,12 @@
#!/usr/bin/env bash
src_dir="lib/src"
src_dir=lib/src
allocation_functions=(malloc calloc realloc free)
allocation_functions=(
malloc
calloc
realloc
free
)
for function in ${allocation_functions[@]}; do
usages=$(grep --line-number -E "\b${function}\(" -r "${src_dir}" --exclude alloc.h )
if [[ ! -z $usages ]]; then
echo "The ${function} function should not be called directly, but is called here:"
echo "$usages"
for function in "${allocation_functions[@]}"; do
usages=$(grep -n -E "\b${function}\(" -r $src_dir --exclude alloc.c --exclude stdlib.c)
if [[ -n $usages ]]; then
printf 'The %s function should not be called directly, but is called here:\n%s\n' "$function" "$usages" >&2
exit 1
fi
done