Automatic add

This commit is contained in:
Timo Schmidt 2023-03-28 15:10:51 +02:00
parent a248f8335b
commit b69b5126d8
1 changed files with 7 additions and 3 deletions

View File

@ -32,8 +32,12 @@ for file in $(find . | grep -v .git | grep '^\./c[[:digit:]][[:digit:]].*.c$');
out_dirpath="${out_dir}/$(dirname "${file}")"
out_filepath="${out_dir}/$(echo "${file}" | sed 's/\.c$/_test.c/g')"
mkdir -p "${out_dirpath}" || { echo "Could not create dir ${out_filepath}. Exiting"; exit 3; }
sed -n "${comment_start},${comment_end}p" "${file}" > "${out_filepath}"
count="$((count + 1))"
sed -n "${comment_start},${comment_end}p" "${file}" > "${out_filepath}.tmp"
diff "${out_filepath}.tmp" "${out_filepath}" >/dev/null
if [ ! "${?}" = "0" ]; then
count="$((count + 1))"
mv "${out_filepath}.tmp" "${out_filepath}"
fi
done
printf '\033[32m%s\033[m\n' "Done, processed ${count} files"
printf '\033[32m%s\033[m\n' "Done, changed ${count} files"