-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.sh
executable file
·62 lines (56 loc) · 1.23 KB
/
script.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
#!/bin/bash
#Libs locations
LIBFT=../libft/
PRINTF=../ft_printf/
GNL=../getnextline/
#Dont touch anything under this (Unless you know what your are doing and are adding in a new project to test)
USRFLS=./userfiles/
#Strings
PATHERROR="Error Missing/Incorrect Path in script.sh"
#Funcs
checkpath(){
if [ ! $1 ] || [ $1 == "../" ] || [ ! -d $1 ] || [ ! "$(ls -A $1)" ]; then
echo "${PATHERROR}"
exit 1
fi
echo $1
}
#Script Start
if (($# != 1)); then exit 1; fi
case $1 in
(libft)
LOC=$(checkpath ${LIBFT});;
(printf)
LOC=$(checkpath ${PRINTF});;
(gnl)
LOC=$(checkpath ${GNL});;
(*)
echo "Error No Valid Tester"
exit 1;
esac
echo -n "Removing old files..."
rm -rf ${USRFLS}
echo "Done"
echo -n "Copying User Files..."
cp -a ${LOC} ${USRFLS}
echo "Done"
echo -n "Checking Norm..."
ERROR=$(norminette ${USRFLS} | grep "Error")
if [[ -n "$ERROR" ]]; then
printf "\e[91mFail\n"
norminette ${USRFLS} | grep "Error"
else
printf "\e[92mPass"
fi
printf "\e[0m\n"
echo -n "Inserting Macros to User Headers..."
HEADERS=$(find ${USRFLS} -type f -name '*.h')
if [[ -n "$HEADERS" ]]; then
for x in ${HEADERS}
do
echo -e "#include \"macros.h\"\n$(cat $x)" > $x
DIR=`dirname $x`
`cp -a ./includes/macros.h ${DIR}`
done
fi
echo "Done"