Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 33 lines (27 sloc) 0.783 kb
d86f2cf @singpolyma status codes, if statements, and test/[
authored
1 #!/bin/sh
2
3 fakeshell() {
4 echo
5 oldifs="$IFS"
6 IFS=""
7 read -p "$ " -r COMMAND
8 IFS="$oldifs"
9 if [ "$COMMAND" = "exit" ]; then exit; fi
10 OUTPUT="`eval "$COMMAND" 2>&1`"
11 echo "$OUTPUT"
12 echo
13 }
14
15 BOLD="\033[1m"
16 NORMAL="\033[0m"
17
18 printf "Right after the error message, a number is printed. The number "
19 printf "is not a 0, so this indicates an error. The shell lets you "
20 printf "get the ${BOLD}exit status code${NORMAL} of the most recent "
21 printf "command using ${BOLD}\$?${NORMAL}."
22 echo; echo
23 printf "What can we do with this? Well, let's start with something "
24 printf "simple.\n"
25
26 OUTPUT=""
27 while ! echo "$OUTPUT" | grep 'not worked' > /dev/null; do
28 printf "Try typing ${BOLD}if mv nothere here; then echo worked; else echo not worked; fi${NORMAL}\n"
29 fakeshell
30 done
31
32 ./step17
Something went wrong with that request. Please try again.