-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmain
More file actions
executable file
·43 lines (37 loc) · 754 Bytes
/
cmain
File metadata and controls
executable file
·43 lines (37 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#/bin/bash
filename="main_template"
file_type=".c"
file=$filename$file_type
file_dir="./$file"
arg1="$1"
if [ "$arg1" == "-rm" ]; # delete .c file
then
rm "$filename"
exit 0
elif [ "$arg1" == "-rr" ]; # delete .c and object file
then
rm "$file_dir"
rm "$filename"
exit 0
elif [ "$arg1" == "-run" ];
then
./"$filename"
exit 0
elif [ "$arg1" == "-c" ];
then
make "$filename"
exit 0
elif [ "$arg1" == "-crun" ];
then
make "$filename"
./"$filename"
exit 0
fi
if [ ! -f "$file_dir" ];
then
touch "$file_dir"
template="#include <stdlib.h>\n#include <stdio.h>\n\nint main(int argc, char *argv[]) {\n\n\n\treturn 0;\n}\n"
echo $template >> "$file_dir"
else
echo "$file ready exists!"
fi