]> zdv2.bktei.com Git - BK-2023-05.git/blob - src/kr_exercises/ch1/s1.2/compile.sh
feat(src/kr):Save state of source files
[BK-2023-05.git] / src / kr_exercises / ch1 / s1.2 / compile.sh
1 #!/usr/bin/env bash
2 # Desc: Compiles all `.c` files in specified directory
3 # Usage: compile.sh [DIR]
4
5 # Check args
6 if [[ ! -d $1 ]]; then echo "FATAL:Not a dir:$1" 1>&2; exit 1; fi;
7
8 for file in ./*.c; do
9 if [[ ! -f $file ]]; then echo "FATAL:Not a file:$file" 1>&2; exit 1; fi;
10 echo "STATUS: file:$file" 1>&2;
11 file_out="${file%.c}";
12 echo "STATUS:file_out:$file_out" 1>&2;
13 gcc -o "$file_out" "$file" || echo "ERROR:Compile failed." 1>&2;
14 echo "" 1>&2;
15 done;