diff --git a/Makefile b/Makefile index 0effd09..19acd39 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,11 @@ STUNAME = 张三 # DO NOT modify the following code!!! -GITFLAGS = -q --author='tracer-ysyx2204 ' --no-verify --allow-empty +TRACER = tracer-ysyx2204 +GITFLAGS = -q --author='$(TRACER) ' --no-verify --allow-empty -WORK_BRANCH = $(shell git rev-parse --abbrev-ref HEAD) -TRACER_BRANCH = ysyx-tracer +YSYX_HOME = $(NEMU_HOME)/.. +TRACER_BRANCH = $(TRACER) # prototype: git_commit(msg) define git_commit diff --git a/init.sh b/init.sh index 3b44360..4cecd43 100644 --- a/init.sh +++ b/init.sh @@ -1,5 +1,14 @@ #!/bin/bash +# usage: addenv env_name path +function addenv() { + sed -i -e "/^export $1=.*/d" ~/.bashrc + echo "export $1=`readlink -e $2`" >> ~/.bashrc + echo "By default this script will add environment variables into ~/.bashrc." + echo "After that, please run 'source ~/.bashrc' to let these variables take effect." + echo "If you use shell other than bash, please add these environment variables manually." +} + # usage: init repo branch directory trace [env] # trace = true|false function init() { @@ -25,12 +34,7 @@ function init() { fi if [ $5 ] ; then - sed -i -e "/^export $5=.*/d" ~/.bashrc - echo "export $5=`readlink -e $3`" >> ~/.bashrc - - echo "By default this script will add environment variables into ~/.bashrc." - echo "After that, please run 'source ~/.bashrc' to let these variables take effect." - echo "If you use shell other than bash, please add these environment variables manually." + addenv $5 $3 fi } @@ -63,20 +67,7 @@ case $1 in fi ;; npc) - sed -i -e "/^export NPC_HOME=.*/d" ~/.bashrc - echo "export NPC_HOME=`readlink -e npc`" >> ~/.bashrc - - echo "By default this script will add environment variables into ~/.bashrc." - echo "After that, please run 'source ~/.bashrc' to let these variables take effect." - echo "If you use shell other than bash, please add these environment variables manually." - ;; - ysyx) - sed -i -e "/^export YSYX_HOME=.*/d" ~/.bashrc - echo "export YSYX_HOME=`readlink -e .`" >> ~/.bashrc - - echo "By default this script will add environment variables into ~/.bashrc." - echo "After that, please run 'source ~/.bashrc' to let these variables take effect." - echo "If you use shell other than bash, please add these environment variables manually." + addenv NPC_HOME npc ;; *) echo "Invalid input..."