#!/bin/bash # First, we'll define some paths to programs that we'll need. This is good # practice for security and it also arguably keeps the script clean CP=/usr/bin/cp ECHO="echo -e" LS="/usr/bin/ls --color=auto" MKDIR=/usr/bin/mkdir MV=/usr/bin/mv RM=/usr/bin/rm SLEEP=/usr/bin/sleep TOUCH=/usr/bin/touch # Next, we'll simplify the mini-quizzes by wrapping them in a function. The # idea behind this is to provide a safe environment for the learner to run # commands in, while still feeling like a bash shell. function test_command { # Usage: test_command while true; do read -p "$TUTOR_PROMPT" command case $command in "$1") $2; break;; *) $ECHO "Hmm, that didn't quite look right. Try typing '$1' and pressing Enter" esac done } function save_progress { # Usage: save_progress cat < ~/.bash_tutor_progress USER=$1 TUTOR_PROMPT="$2" PROGRESS=$3 EOF } cat <