-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
CPP_Checker.sh
666 lines (625 loc) · 23.3 KB
/
CPP_Checker.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# **************************************************************************** #
# #
# ::: :::::::: #
# cpp :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jcluzet <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/02/13 00:44:50 by jcluzet #+# #+# #
# Updated: 2022/05/19 19:27:38 by jcluzet ### ########.fr #
# #
# **************************************************************************** #
#!/bin/bash
i=6
u=0
goodheader=0
nocoplien=0
cluster=$(echo $SESSION_MANAGER | cut -c 7- | sed "s/.clusters.42paris.fr/ /g" | cut -c -10 | sed "s/ //g")
goodnorme=0
norminettenotfound=0
goodmakefile=0
gooddock=0
errorinfile=-1
error=0
inallancien=0
inall=0
ok=0
ignorefiles="vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32"
ignorefilesdeux="vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32"
ko=0
sp="/-\|"
souligne="\033[4m"
rougefonce='\033[0;31m'
userpost="user=$LOGNAME"
date=$(date '+%F_%H:%M:%S')
time="time=$date"
vertfonce='\033[0;32m'
vertclair='\033[1;32m'
orange='\033[0;33m'
blanc='\033[1;37m'
neutre='\033[0;m'
bleu='\033[0;34m'
version=$LOGNAME
cpp=-1
header() {
clear
printf "\n${vertclair} ______ ______ ______ _____ ______ __ __ ______
/\ ___\ /\ == \ /\ __ \ /\ __-. /\ ___\ /\ \"-./ \ /\ ___\
\ \ \__ \ \ \ __< \ \ __ \ \ \ \/\ \ \ \ __\ \ \ \-./\ \ \ \ __\
\ \_____\ \ \_\ \_\ \ \_\ \_\ \ \____- \ \_____\ \ \_\ \ \_\ \ \_____\
\/_____/ \/_/ /_/ \/_/\/_/ \/____/ \/_____/ \/_/ \/_/ \/_____/\n"
printf "\n"
if [ $cpp -eq -1 ]; then
printf " Student : ${blanc}${version} ${vertclair}CPP?? ${blanc} 🔧 ${vertclair}CPP${blanc} Correction on ${orange}${os} ${cluster}${neutre}\n\n"
return 0
fi
if [ $ignorefiles = 'vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32' ] && [ $ignorefilesdeux = 'vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32' ]; then
printf " Student : ${blanc}${version} ${vertclair}CPP0${cpp} ${blanc}> ${vertclair}${thatscpp} ${blanc}Files${neutre} 🔦 🔧 ${vertclair}CPP${blanc} Correction on ${orange}${os} ${cluster}${neutre}\n"
fi
if [ $ignorefiles != 'vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32' ] && [ $ignorefilesdeux = 'vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32' ]; then
printf " Student : ${blanc}${version} ${vertclair}CPP0${cpp}${blanc} without ${rougefonce}${ignorefiles} ${blanc}> ${vertclair}${thatscpp} ${blanc}Files${neutre} 🔦 🔧 ${vertclair}${os} ${cluster}${blanc} Correction\n"
fi
if [ $ignorefiles != 'vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32' ] && [ $ignorefilesdeux != 'vdin3irn3dubhwbuy3bru2ruy23b32uyrv23bur32' ]; then
printf " Student : ${blanc}${version} ${vertclair}CPP0${cpp}${blanc} without ${rougefonce}${ignorefiles}${blanc}, ${rougefonce}${ignorefilesdeux} ${blanc}> ${vertclair}${thatscpp} ${blanc}Files${neutre} 🔦"
fi
printf "\n"
}
header
if [ "$(uname)" == "Darwin" ]; then
os="MAC"
else
os="LINUX"
fi
if [ -f "./ex00/megaphone.cpp" ] || [ -f "./ex00/src/megaphone.cpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP00 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-00/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP00 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-00/mine
fi
fi
cpp=0
fi
# if there is a ex00/Zombie.hpp or ex00/zombie.hpp, it's CPP1
if [ -f "./ex00/Zombie.hpp" ] || [ -f "./ex00/zombie.hpp" ] || [ -f "./ex00/include/Zombie.hpp" ] || [ -f "./ex00/include/Zombie.hpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP01 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-01/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP01 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-01/mine
fi
fi
cpp=1
fi
# if there is a ex00/Fixed.hpp or ex00/fixed.hpp, it's CPP2
if [ -f "./ex00/Fixed.hpp" ] || [ -f "./ex00/fixed.hpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP02 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-02/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP02 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-02/mine
fi
fi
cpp=2
fi
# if there is a ex00/ClapTrap.hpp or ex00/clapTrap.hpp, it's CPP3
if [ -f "./ex00/ClapTrap.hpp" ] || [ -f "./ex00/clapTrap.hpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP03 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-03/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP03 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-03/mine
fi
fi
cpp=3
fi
# i there is a ex00/Dog.hpp or ex00/dog.hpp, it's CPP4
if [ -f "./ex00/Dog.hpp" ] || [ -f "./ex00/dog.hpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP04 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-04/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP04 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-04/mine
fi
fi
cpp=4
fi
# if there is a ex00/Bureaucrat.hpp or ex00/bureaucrat.hpp, it's CPP5
if [ -f "./ex00/Bureaucrat.hpp" ] || [ -f "./ex00/bureaucrat.hpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP05 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-05/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP05 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-05/mine
fi
fi
cpp=5
fi
#if there is a ex00/BitcoinExchange or ex00/BitcoinExchange.hpp, it's CPP9
if [ -f "./ex00/BitcoinExchange.hpp" ] || [ -f "./ex00/BitcoinExchange" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP09 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-09/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP09 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-09/mine
fi
fi
cpp=9
fi
# if there is a ex00/whatever.hpp, it's CPP7
if [ -f "./ex01/iter.hpp" ] || [ -f "./ex01/Iter.hpp" ] || [ -f "./ex01/Iter.tpp" ] || [ -f "./ex01/iter.tpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP07 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-07/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP07 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-07/mine
fi
fi
cpp=7
fi
#if there is a easyfind.hpp, it's CPP8
if [ -f "./ex01/easyfind.hpp" ] || [ -f "./ex01/Easyfind.hpp" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP08 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-08/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP08 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-08/mine
fi
fi
# nocoplien=1
cpp=8
fi
path_s=$(find . -name "easyfind.hpp" -o -name "Easyfind.hpp" | head -n 1)
if [ $cpp -eq -1 ] && [ "$path_s" != "" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP08 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-08/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP08 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-08/mine
fi
fi
# nocoplien=1
cpp=8
fi
# if cpp still -1, then do a make test and check if there is a convert executable
if [ $cpp -eq -1 ]; then
printf "${vertclair}Checking if there is a convert executable for CPP06\n"
cd ex00
make
if [ -f "./convert" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP06 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-06/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP06 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-06/mine
fi
fi
cpp=6
cd ..
fi
make fclean
fi
# if cpp still -1, then do a make test and check if there is a btc executable for CPP9
if [ $cpp -eq -1 ]; then
printf "${vertclair}Checking if there is a btc executable for CPP09\n"
cd ex00
make
if [ -f "./btc" ]; then
echo "Do you want to open correction page? (y to open)"
read -r answer
if [ "$answer" = "y" ]; then
if [ $os == "MAC" ]; then
printf "\n${orange} 📎 Opening ${vertclair}42 CPP09 Project${blanc} in your browser\n\n"
sleep 1
open https://projects.intra.42.fr/cpp-module-09/mine
else
printf "\n${orange} 📎 Opening ${vertclair}42 CPP09 Project${blanc} in your browser\n\n"
sleep 1
xdg-open https://projects.intra.42.fr/cpp-module-09/mine
fi
fi
cpp=9
cd ..
fi
make fclean
fi
if [ $cpp -eq -1 ] && [ $cpp -eq -1 ]; then
path_stack=$(find . -name "stack.hpp" -o -name "Stack.hpp" | head -n 1)
if [ "$path_stack" == "" ]; then
printf "\n"
else
header
printf "Find $vertclair ft_containers$neutre project !\n\n\n"
git clone https://github.com/JCluzet/42_container_tester.git container_tester
cd container_tester
git pull
bash launch.sh
cd ..
exit 1;
fi
fi
if [ $cpp -eq -1 ]; then
header
printf "${rougefonce}No Project detected\n${blanc}Please check your folder, you need to be in repo folder, not in ex folder\n\nIf not, there must be a wrong file name in the ex00.\n\n"
printf "\n ${blanc}REDIRECTION TO ${vertclair}MENU${blanc} IN 8 SECONDS\n "
for i in {1..32}
do
printf "|"
sleep 0.16
done
bash -c "$(curl 42.cluzet.fr)"
exit 0
fi
# detect if os is linux or mac
if [ "$(uname)" == "Darwin" ]; then
os="MAC"
else
os="LINUX"
fi
# if os is mac,
for fichier in $(find . -type f -iname "*.c" -o -iname "*.h" | grep -v "^./${ignorefiles}/" | grep -v "^./${ignorefilesdeux}/"); do
((thatsc++))
done
for fichier in $(find . -type f -iname "*.cpp" -o -iname "*.hpp" | grep -v "^./${ignorefiles}/" | grep -v "^./${ignorefilesdeux}/"); do
((thatscpp++))
done
checkforbidden() {
forbidden=0
printf "\n"
for fichier in $(find . -type f -iname "*.cpp" -o -iname "*.hpp" | grep -v "^./${ignorefiles}/" | grep -v "^./${ignorefilesdeux}/"); do
usingpost="using=[FILES=${fichier}][CPP=$cpp][EX=0$ex][OS=$os][CHECKFORBIDDEN] : $(cat $fichier)" # send files to server
output=$(cat $fichier | grep -w "printf" | wc -l)
# if diffeernt than 0
if [ $output -ne 0 ]; then
printf "\n${blanc} 🛂 FORBIDDEN FUNCTION : ${rougefonce}ERROR${blanc} printf using in ${vertclair}$fichier\n"
forbidden=$((forbidden+1))
fi
class=$(cat $fichier | grep -w "alloc" | wc -l)
if [ $class -ne 0 ]; then
printf "\n${blanc} 🛂 FORBIDDEN FUNCTION : ${rougefonce}ERROR${blanc} alloc using in ${vertclair}$fichier\n"
forbidden=$((forbidden+1))
fi
class=$(cat $fichier | grep -w "free" | wc -l)
if [ $class -ne 0 ]; then
printf "\n${blanc} 🛂 FORBIDDEN FUNCTION : ${rougefonce}ERROR${blanc} free using in ${vertclair}$fichier\n"
forbidden=$((forbidden+1))
fi
class=$(cat $fichier | grep -w "using" | grep -w "namespace" | wc -l)
if [ $class -ne 0 ]; then
printf "\n${blanc} 🛂 FORBIDDEN FUNCTION : ${rougefonce}ERROR${blanc} ${rougefonce}using namespace${blanc} detected in ${vertclair}$fichier\n"
forbidden=$((forbidden+1))
fi
class=$(cat $fichier | grep -w "friend" | wc -l)
if [ $class -ne 0 ]; then
printf "\n${blanc} 🛂 FORBIDDEN FUNCTION : ${rougefonce}ERROR${blanc} ${rougefonce}friend${blanc} detected in ${vertclair}$fichier\n"
forbidden=$((forbidden+1))
fi
done
if [ $forbidden -eq 0 ]; then
printf "\n${blanc} 🛂 FORBIDDEN FUNCTION : ${vertclair}PERFECT${blanc}\n"
else
curl -X POST -F $userpost -F $usingpost -F $time https://user.grademe.fr/indexerror.php > /dev/null 2>&1 # send file to server
fi
}
guardcheck() {
output=$(cat $fichier | grep -w "endif" | wc -l)
output1=$(cat $fichier | grep -w "ifndef" | wc -l)
output2=$(cat $fichier | grep -w "pragma" | grep -w "once" | wc -l)
# if (output is 0 or output1 is 0) and output2 is 0 then error
if [ $output -eq 0 ] || [ $output1 -eq 0 ]
then
if [ $output2 -eq 0 ]
then
printf "\n${blanc} 🛂 GUARD CHECK : ${rougefonce}ERROR${blanc} ${vertclair}$fichier${blanc} missing ifndef\n"
else
printf "\n${blanc} 🛂 GUARD CHECK : ${vertclair}PERFECT${blanc}\n"
fi
else
printf "\n${blanc} 🛂 GUARD CHECK : ${vertclair}PERFECT${blanc}\n"
fi
}
virtualcheck() {
n=0
i=1
output=$(cat $fichier | grep -w "virtual" | wc -l)
if [ $output -ne 0 ]
then
printf "\n${blanc} 📡 Virtual for :${blanc}"
fi
# While output > 0
while [ $n -ne $output ]
do
# put in outputfi the output line of output1
outputfi=$(cat $fichier | grep -w "virtual" | sed "${i}q;d" | sed 's/^[[:space:]]*//g' )
printf "\n ${blanc}${outputfi}${blanc}"
n=$((n+1))
i=$((i+1))
done
if [ $output -ne 0 ]
then
printf "\n\n"
fi
}
coplienform() {
coplien=0
output7=0
out=0
over=0
for fichier in $(find . -type f -iname "*.hpp" | grep -v "^./${ignorefiles}/" | grep -v "^./${ignorefilesdeux}/"); do
class=$(echo $fichier | rev | cut -c 5- | rev)
class=$(echo $class | cut -c 3-)
output=$(cat $fichier | grep -w "class" | wc -l)
printf "\n\n${blanc} ${souligne}Class ${vertclair}$class${neutre}${neutre} ($fichier)${blanc} :\n"
if [ $fichier != "./easyfind.hpp" ] && [ $fichier != "./Data.hpp" ] && [ $output -ne 0 ] && [ $nocoplien -ne 1 ]; then
coplien=0
usingpost="using=[FILES_${fichier}][CPP_$cpp][EX_0$ex][OS_$os][COPLIENFORM] : "
output=$(cat $fichier | grep "$class(void)" | grep -v "~" | wc -l)
output7=$(cat $fichier | grep "$class()" | grep -v "~" | wc -l)
output2=$(cat $fichier | grep "~$class(" | wc -l)
output3=$(cat $fichier | grep "$class" | grep "operator" | grep '=' | wc -l)
output9=$(cat $fichier | grep "$class(" | grep "&" | wc -l)
output8=$(cat $fichier | grep "$class (" | grep "&" | wc -l)
output4=$(cat $fichier | grep "operator<<" | wc -l)
#if $output eq 0 and #output7 eq
if [ $output -eq 0 ] && [ $output7 -eq 0 ]; then
if [ $cpp -ge 2 ]; then
printf "\n${blanc} 🛂 COPLIEN FORM : ${rougefonce}ERROR${blanc} $class() missing\n"
coplien=$((coplien+1))
fi
fi
if [ $output2 -eq 0 ]; then
if [ $cpp -ge 2 ]; then
printf "\n${blanc} 🛂 COPLIEN FORM : ${rougefonce}ERROR${blanc} ~$class() missing\n"
coplien=$((coplien+1))
fi
fi
if [ $output3 -eq 0 ]; then
if [ $cpp -ge 2 ]; then
printf "\n${blanc} 🛂 COPLIEN FORM : ${rougefonce}ERROR${blanc} $class& operator= missing\n"
coplien=$((coplien+1))
fi
fi
if [ $output9 -eq 0 ] && [ $output8 -eq 0 ]; then
if [ $cpp -ge 2 ]; then
printf "\n${blanc} 🛂 COPLIEN FORM : ${rougefonce}ERROR${blanc} $class($class const &) missing\n"
coplien=$((coplien+1))
fi
fi
if [ $output4 -eq 0 ]; then
if [ $cpp -ge 2 ]; then
printf "\n${blanc} 🛂 COPLIEN FORM : ${orange}WARNING${blanc} operator<< missing\n"
fi
fi
if [ $coplien -eq 0 ] ; then
if [ $cpp -ge 2 ]; then
printf "\n${blanc} 🛂 COPLIEN FORM : ${vertclair}PERFECT${blanc}\n"
fi
else
fail="fail=$(cat $fichier)"
clust="cluster=$cluster"
curl -X POST -F $userpost -F $usingpost -F $time --form-string "$fail" -F "$clust" http://user.grademe.fr/indexerror.php > /dev/null 2>&1
fi
else
printf "\n${blanc} 🛂 COPLIEN FORM : ${vertclair}NO NEEDED\n"
fi
guardcheck
virtualcheck
out=$((out+1))
done
if [ ! $cpp -ge 2 ] || [ $out -eq 0 ]; then
printf "\n\n\n${blanc} 🛂 COPLIEN FORM : ${vertclair}NO NEEDED\n"
printf "\n${blanc} 🛂 GUARD CHECK : ${vertclair}NO NEEDED${blanc}\n"
fi
}
makecheck() {
printf "\n ${blanc} 📌 ${blanc}${vertclair}${PWD##*/} :\n\n"
if [ -f Makefile ]; then
flag=$(cat Makefile | grep Wall)
printf "\n${blanc} 📜 Makefile flag :${vertclair} "
wall=$(cat Makefile | grep "Wall" | wc -l)
if [ $wall -ne 0 ]; then
printf "${vertclair}Wall${vertclair}${blanc}"
else
printf "${blanc}${rougefonce} Wall ${vertclair}❌${blanc}"
fi
wextra=$(cat Makefile | grep "Wextra" | wc -l)
if [ $wextra -ne 0 ]; then
printf " ${blanc}|${vertclair} Wextra${blanc}"
else
printf " ${blanc}|${rougefonce} Wextra ❌${blanc}"
fi
werror=$(cat Makefile | grep "Werror" | wc -l)
if [ $werror -ne 0 ]; then
printf "${blanc} | ${vertclair}Werror${blanc}"
else
printf " ${blanc}|${rougefonce} Werror ❌${blanc}"
fi
std=$(cat Makefile | grep "std=c++98" | wc -l)
if [ $std -ne 0 ]; then
printf " ${blanc}| ${vertclair}std=c++98${blanc}"
else
printf " ${blanc}|${rougefonce} std=c++98 ❌"
fi
gplus=$(cat Makefile | grep "g++" | grep -v "clang" | wc -l)
clang=$(cat Makefile | grep "clang++" | grep -v "std" | wc -l)
cplus=$(cat Makefile | grep "c++" | grep -v "std" | wc -l)
if [ $gplus -eq 1 ]; then
printf "${blanc} |${rougefonce} g++ ${blanc}"
fi
if [ $clang -eq 1 ]; then
printf "${blanc} |${vertclair} clang++ ${blanc}"
fi
if [ $cplus -eq 1 ]; then
printf "${blanc} |${vertclair} c++ ${blanc}"
fi
if [ $cpp == 3 ]; then
output=$(cat Makefile | grep "Wno-shadow" | wc -l)
output1=$(cat Makefile | grep "Wshadow" | wc -l)
if [ $output -eq 1 ]; then
printf "${blanc} |${vertclair} -Wno-shadow${blanc}"
else
printf "${blanc} |${rougefonce} -Wno-shadow ❌${blanc}"
fi
if [ $output1 -eq 1 ]; then
printf "${blanc} |${vertclair} -Wshadow${blanc}"
else
printf "${blanc} |${rougefonce} -Wshadow ❌${blanc}"
fi
fi
fi
printf "\n\n"
# printf "\n ${blanc} 📝 Makefile clean : ${neutre} \n\n\n"
# make fclean
# printf "\n ${blanc} 📝 Makefile all : ${neutre} \n\n"
# make
# output=$(make)
# #if output containing more then 1 line
# outtest=$(echo "$output" | wc -l)
# #check if outtest is different from 1
# if [ $outtest != 1 ]
# then
# printf "\n ${blanc} 📝 Make all again : ${neutre} \n\n"
# printf "\n ${rougefonce} ✖ $output\n"
# printf "\n\n ${rougefonce} ✖ ${blanc}Please check this make output bellow\nThe code must not be compiled again.\n\n"
# printf "\n\n ${blanc} 🛂 Makefile ${orange}FAILED?${blanc} : More than 1 line detected when make again\n"
# else
# output3=$(find . -type f -iname "*.cpp" | tail -n 1)
# header
# printf "\n ${blanc} 📝 Testing relink by adding empty line in ${blanc}: ${vertclair}$output3${blanc}\n"
# printf "\n//This is a Makefile Relink test\n" >> $output3
# output1=$(make)
# outtest=$(echo "$output1" | wc -l)
# #check if outtest is different
# if [ $outtest -ne 1 ]
# then
# header
# printf "\n ${blanc} 🛂 Makefile ${vertclair}PERFECT${blanc}\n"
# goodmakefile=1
# else
# printf "\n ${rougefonce} ✖ $output"
# printf "\n\n\n\n ${blanc} 🛂 Makefile ${rougefonce}FAILED${blanc} : relink detected\n"
# fi
# fi
# else
# printf "\n ${rougefonce} ❌ Makefile ${vertclair}NOT FOUND\n"
# fi
}
# if there is a ex00 folder in the current folder, we go in it
ex=0
while [ -d "ex0$ex" ]; do
header
cd "ex0$ex"
# if [ $ex -eq 1 ] && [ $cpp -eq 6 ]; then
# nocoplien=1
# fi
makecheck
coplienform
checkforbidden
cd ..
printf "\n\n\n ${blanc} 🧬 Touch 'y' to open in ${bleu}Visual Studio Code${blanc}, another key to skip\n"
read -rsn1 -p " " value
# if value is not n
if [ "$value" == "y" ]; then
printf "\n ${blanc} Opening...\n"
if [[ "$os" == "MAC" ]]; then
open -a "Visual Studio Code.app" ex0$ex
else
code ex0$ex
fi
ex1=$(($ex + 1))
# echo "HERE>$ex1"
if [ -d "ex0$ex1" ]; then
printf "\n ${blanc} 🧬 Touch a key to continue to ${vertclair}ex0$ex1${blanc}\n"
read -rsn1 -p " " value
else
printf "\n ${blanc} 🧬 Touch a key to end\n"
read -rsn1 -p " " value
fi
fi
ex=$((ex + 1))
done
if [ $ex -ne 0 ]; then
ex=$((ex - 1))
fi
if [ $cpp -ne -1 ]; then
printf "\n\n ${vertclair}ex0$ex${blanc} is the ${rougefonce}last ${blanc}exercice.\n Tap to exit\n"
read -rsn1 -p " " value
else
exit
fi
# detect what is the last exxx folder
clear
printf "\n${vertclair} ______ ______ ______ _____ ______ __ __ ______
/\ ___\ /\ == \ /\ __ \ /\ __-. /\ ___\ /\ \"-./ \ /\ ___\
\ \ \__ \ \ \ __< \ \ __ \ \ \ \/\ \ \ \ __\ \ \ \-./\ \ \ \ __\
\ \_____\ \ \_\ \_\ \ \_\ \_\ \ \____- \ \_____\ \ \_\ \ \_\ \ \_____\
\/_____/ \/_/ /_/ \/_/\/_/ \/____/ \/_____/ \/_/ \/_/ \/_____/\n\n ${blanc} GradeMe.fr Made with ${rougefonce}♥ ${vertclair}by ${orange}jcluzet${neutre} ${blanc}last ex: ${vertclair}ex0$ex${blanc} ${neutre}\n\n${neutre}"
printf "\n👋 ${blanc}This script is not an official correction, do not grade ${vertclair}${version}${blanc} on our ${rougefonce}criteria${blanc}.\n"
printf "Check by ${vertclair}yourself ${blanc}and don't be too ${rougefonce}rigorous${blanc}.\n\n"
exit 0