0

I copied a script from bash tldp tutorial web-site. http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-9.html Trying to run this, I am getting the following error: only "else part" is working.

OPTIONS="Hello Quit"
           select opt in $OPTIONS; do
               if [ "$opt" = "Quit" ]; then
                echo done
                exit
               elif [ "$opt" = "Hello" ]; then
                echo "Hello World"
               else
                clear
                echo bad option
               fi
           done
Soren A
  • 6,442
  • 2
  • 17
  • 33
Josef Klimuk
  • 1,566
  • 5
  • 21
  • 36
  • it works for me (at least doing what I think it should do)... I don't know why they put the `clear` and why `if else` instead of the more common `case ... esac`. – pLumo Aug 22 '19 at 10:32
  • 1
    How are you testing it, exactly? the `select` builtin expects you to type the *number* that is displayed alongside the selection - if you are typing the selection itself (`Hello` or `Quit`) it will be treated as a "bad option" – steeldriver Aug 22 '19 at 12:14
  • 1
    Please [edit] your question and explain i) exactly how you are launching the script, using what command, ii) exactly what input you give it, iii) what you expect from that input and iv) what actually happens. We can't help you debug the behavior if you don't explain what the behavior is. – terdon Aug 22 '19 at 12:47
  • I am getting "bad option #?" and it does not depend which option I am choosing – Josef Klimuk Sep 01 '19 at 06:08

0 Answers0