summaryrefslogtreecommitdiff
path: root/bin/problem-13.sh
blob: 9322cd22fb155bd0ec852921249a9a6b6348c759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

banner() {
  echo "Use one of the following options:"
  echo "    d: To display today's date and present time"
  echo "    l: To see the listing of files in your present working directory"
  echo "    w: To see who's logged in"
  echo "    q: To quit this program"
  echo "Enter your option and hit <Enter>:"
}

quit() {
  exit 0
}
list() {
  ls
}
print_date() {
  date
}
logged_in() {
  who
}

menu() {
  read option
  case "$option" in
    d) print_date
      ;;
    l) list
      ;;
    w) logged_in
      ;;
    q) quit
      ;;
  esac
}

main() {
  while true; do
    banner
    menu
  done
  quit
}

main