Skip to content
Snippets Groups Projects
Commit 1f6bb0a6 authored by ricardo.dossanto1's avatar ricardo.dossanto1
Browse files

added a prototype of exam creating script

parent 3199ee9d
Branches
No related tags found
No related merge requests found
File moved
#!/bin/bash
shopt -s -o nounset
declare EXAM_NAME
declare DIRECTORY=""
declare NBR_EXO=1
declare LOOP_START=1
if test $# -lt 2; then
echo "Usage: $0 EXAM_NAME nbrExercices"
exit -1
fi
EXAM_NAME=$1
if ! [[ "$2" =~ ^[0-9]+$ ]]
then
echo "$2 is not a number (integer)"
exit -5
fi
NBR_EXO=$2
cd $(pwd)
if [[ "$EXAM_NAME" =~ ( |\') ]]; then
echo "EXAM_NAME should not contain spaces"
exit -2
fi
if test -d "$EXAM_NAME"; then
echo "DIRECTORY already exists, please choose another name"
exit -4
fi
mkdir $EXAM_NAME
if test ! -d "$EXAM_NAME"; then
echo "mkdir creation failed, aborting..."
exit -3
fi
cd $EXAM_NAME
# git init
touch ".gitignore"
echo -e "### C ### \n*.o\n*.exe\n*.out\n*.app" > .gitignore
for (( k=$LOOP_START; k<=$NBR_EXO; k++ ))
do
if test -d "exo${k}"; then
echo "One of the exo directory already exists, aborting"
exit -4
fi
mkdir "exo${k}"
cd "exo${k}"
touch "Makefile"
echo -e "#the compiler\nCC:=gcc\nCFLAGS:=-g -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11 \n#linker flags\nLDFLAGS:=-lm -lSDL2 -fsanitize=address\n\nFNAME:=exo${k}\n\nexo${k}: exo${k}.o\n\t\$(CC) -o \$@ \$^ \$(LDFLAGS)\n\t./exo${k}\nclean:\n\t@rm -f *.o exo${k}" > Makefile
# exit 0
touch "exo${k}.c"
echo -e "int main(void){\n}" > "exo${k}.c"
cd ..
done
echo $(git remote add origin ssh://git@ssh.hesge.ch:10572/ricardo.dossanto1/${EXAM_NAME})
declare BRANCH_NAME=$(git config init.defaultBranch)
echo $BRANCH_NAME
echo $(git add .)
echo $(git commit -m "Auto commit generation via script")
echo $(git push -u origin ${BRANCH_NAME})
exit 0
#!/bin/bash
shopt -s -o nounset
declare start=0
declare end=5
for (( k=$start; k<=$end; k++ ))
do
echo $k
done
### C ###
*.o
*.exe
*.out
*.app
#the compiler
CC:=gcc
CFLAGS:=-g -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11
#linker flags
LDFLAGS:=-lm -lSDL2 -fsanitize=address
FNAME:=exo1
exo1: exo1.o
$(CC) -o $@ $^ $(LDFLAGS)
./exo1
clean:
@rm -f *.o exo1
int main(void){
}
#the compiler
CC:=gcc
CFLAGS:=-g -Wall -Wextra -fsanitize=address -fsanitize=leak -std=gnu11
#linker flags
LDFLAGS:=-lm -lSDL2 -fsanitize=address
FNAME:=exo2
exo2: exo2.o
$(CC) -o $@ $^ $(LDFLAGS)
./exo2
clean:
@rm -f *.o exo2
int main(void){
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
shopt -s -o nounset shopt -s -o nounset
declare TP_NAME declare TP_NAME
declare DIRECTORY="" declare DIRECTORY="/home/rickyy/Desktop"
if test $# -lt 1; then if test $# -lt 1; then
echo "Usage: $0 TP_NAME" echo "Usage: $0 TP_NAME"
...@@ -49,9 +49,11 @@ echo -e "#ifndef _${TP_NAME^^}_H_\n#define _${TP_NAME^^}_H_\n#include <stdio.h>\ ...@@ -49,9 +49,11 @@ echo -e "#ifndef _${TP_NAME^^}_H_\n#define _${TP_NAME^^}_H_\n#include <stdio.h>\
pwd pwd
echo $(git remote add origin ssh://git@ssh.hesge.ch:10572/ricardo.dossanto1/${TP_NAME}) echo $(git remote add origin ssh://git@ssh.hesge.ch:10572/ricardo.dossanto1/${TP_NAME})
declare BRANCH_NAME=$(git config init.defaultBranch)
echo $BRANCH_NAME
echo $(git add .) echo $(git add .)
echo $(git commit -m "Auto commit generation via script") echo $(git commit -m "Auto commit generation via script")
echo $(git push -u origin master) echo $(git push -u origin ${BRANCH_NAME})
#cd "/home/ricky/Desktop/" #cd "/home/ricky/Desktop/"
#rm -r $TP_NAME #rm -r $TP_NAME
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment