So I am new to the whole Bash scripting scene, but I am working on a script to compile all the .c files in a directory which I have succeeded in doing so by:
for F in *.c; do
gcc -c -Wall -o ${F%.c} $F
done
Everything works fine, but I want to the output to look something like:
ex1.c Errors
ex2.c OK
ex3.c Warnings
So basically I want to have an exit status of 0 (Everything went fine) for "Ok", status 1 (Warnings, but no error) for "Warnings" and status 2 (Did not compile) for "Errors".
I am having a hard time figuring out how to do such a thing. I've searched around and couldn't find anything that I have found to be useful. I very well could have overlooked something though.
EDIT: Would there be anyway to say: if gcc -Wall file.c has errors, then just say Error instead of the full GCC error handling message? Same with warnings and a perfect compile?