diff --git a/configure.sh b/configure_tp_script.sh similarity index 100% rename from configure.sh rename to configure_tp_script.sh diff --git a/exam_create.sh b/exam_create.sh new file mode 100755 index 0000000000000000000000000000000000000000..5d82252449dbb83748f21e67c862b754cc6ff7aa --- /dev/null +++ b/exam_create.sh @@ -0,0 +1,80 @@ +#!/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 diff --git a/test.sh b/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..9981f7d7b509a58ed6e6c091fb4cb1bddcad0736 --- /dev/null +++ b/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +shopt -s -o nounset +declare start=0 +declare end=5 +for (( k=$start; k<=$end; k++ )) +do + echo $k +done diff --git a/testExam/.gitignore b/testExam/.gitignore deleted file mode 100644 index 7405c3851c5c30c683c27be3117bc36546e98c88..0000000000000000000000000000000000000000 --- a/testExam/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -### C ### -*.o -*.exe -*.out -*.app diff --git a/testExam/exo1/Makefile b/testExam/exo1/Makefile deleted file mode 100644 index ce4a545b87dd6786115e14cb3214bc17bd098524..0000000000000000000000000000000000000000 --- a/testExam/exo1/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -#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 diff --git a/testExam/exo1/exo1.c b/testExam/exo1/exo1.c deleted file mode 100644 index 1e9a8823c11a248c1bf1c8f3631a9c045d423e38..0000000000000000000000000000000000000000 --- a/testExam/exo1/exo1.c +++ /dev/null @@ -1,2 +0,0 @@ -int main(void){ -} diff --git a/testExam/exo2/Makefile b/testExam/exo2/Makefile deleted file mode 100644 index b4031d502f12243d202b733cb9a7e77e7aada671..0000000000000000000000000000000000000000 --- a/testExam/exo2/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -#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 diff --git a/testExam/exo2/exo2.c b/testExam/exo2/exo2.c deleted file mode 100644 index 1e9a8823c11a248c1bf1c8f3631a9c045d423e38..0000000000000000000000000000000000000000 --- a/testExam/exo2/exo2.c +++ /dev/null @@ -1,2 +0,0 @@ -int main(void){ -} diff --git a/tp_create.sh b/tp_create.sh index f2d071cfd2caba7df354f50afc58f7098e7d0a56..d342f3c5ef86ddcc57c45eb25e279c9d25970ddf 100755 --- a/tp_create.sh +++ b/tp_create.sh @@ -3,7 +3,7 @@ shopt -s -o nounset declare TP_NAME -declare DIRECTORY="" +declare DIRECTORY="/home/rickyy/Desktop" if test $# -lt 1; then echo "Usage: $0 TP_NAME" @@ -49,9 +49,11 @@ echo -e "#ifndef _${TP_NAME^^}_H_\n#define _${TP_NAME^^}_H_\n#include <stdio.h>\ pwd 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 commit -m "Auto commit generation via script") -echo $(git push -u origin master) +echo $(git push -u origin ${BRANCH_NAME}) #cd "/home/ricky/Desktop/" #rm -r $TP_NAME