reorganize control
This commit is contained in:
@ -29,19 +29,7 @@ function bashtutor_wrap() {
|
|||||||
return $r
|
return $r
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -ne 0 ]; then # Initial call
|
||||||
LAST_CMD="$(history | tail -n 1 | cut -c 8-)"
|
|
||||||
|
|
||||||
bashtutor_wrap validate $LAST_CMD
|
|
||||||
if [ $? == 1 ]; then
|
|
||||||
BASHTUTOR_PROGRESS=$(expr $BASHTUTOR_PROGRESS + 1)
|
|
||||||
|
|
||||||
[ -z "${BASHTUTOR_TASK_FILE_LIST[$BASHTUTOR_PROGRESS]}" ] && bashtutor_completed
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
task
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
BASHTUTOR_PROGRESS=0
|
BASHTUTOR_PROGRESS=0
|
||||||
BASHTUTOR_MODULE_DIRNAME=$(dirname $1)
|
BASHTUTOR_MODULE_DIRNAME=$(dirname $1)
|
||||||
@ -57,10 +45,22 @@ else
|
|||||||
alias hint='bashtutor_wrap hint'
|
alias hint='bashtutor_wrap hint'
|
||||||
|
|
||||||
PROMPT_COMMAND=()
|
PROMPT_COMMAND=()
|
||||||
PROMPT_COMMAND="source ${PWD}/bashtutor_helper"
|
PROMPT_COMMAND="BASHTUTOR_R=\$?; source ${PWD}/bashtutor_helper"
|
||||||
|
|
||||||
bashtutor_greet $1
|
bashtutor_greet $1
|
||||||
|
|
||||||
bashtutor_wrap description
|
bashtutor_wrap description
|
||||||
set +o errexit
|
set +o errexit
|
||||||
|
else # Event callback
|
||||||
|
LAST_CMD="$(history | tail -n 1 | cut -c 8-)"
|
||||||
|
|
||||||
|
bashtutor_wrap validate $LAST_CMD
|
||||||
|
if [ $? == 1 ]; then
|
||||||
|
BASHTUTOR_PROGRESS=$(expr $BASHTUTOR_PROGRESS + 1)
|
||||||
|
|
||||||
|
[ -z "${BASHTUTOR_TASK_FILE_LIST[$BASHTUTOR_PROGRESS]}" ] && bashtutor_completed
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
task
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user