What does ENDOFMENU do?

Posted by Raymond on Ask Ubuntu See other posts from Ask Ubuntu or by Raymond
Published on 2012-09-16T21:08:49Z Indexed on 2012/09/16 21:52 UTC
Read the original article Hit count: 313

Filed under:
|

I have been given an example program, I am wondering what exactly the <<ENDOFMENU and ENDOFMENU does, won't it work the same if you leave it out and just use the while loop?

#!/bin/sh
echo "Menu test program...";
stop=0;
while test $stop -eq 0; do
cat<<ENDOFMENU
1: print the date
2,3 : print the current working directory
4: exit
ENDOFMENU
  echo; echo -e "your choice?\c"
  read reply
echo
case $reply in
    "1")
       date
;;
    "2"|"3")
       pwd
;;
    "4")
      stop=1
;;
    *)
      echo illegal choice
  esac
done

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about shell-scripting