[uug] newbie help: bash script question

Ryan Johnson bismark90 at gmail.com
Fri Apr 18 12:11:46 MDT 2008


i tried sending this to the newbie list but i guess its still hasn't  
been brought back to life.

i am trying to write a short script that asks the user a yes or no  
question.  if he/she input y or Y, i want to continue, if not, i want  
to exit.  i have the following code:

read choice
if [ $choice != 'y' -a $choice != 'Y' ]; then
		exit 0
fi

it works except in the case that the user just hits the enter key.  if  
they do, it outputs:

line 24: [: too many arguments

and then continues execution.  i would appreciate any help with my  
syntax.  thanks!

-ryan



More information about the uug-list mailing list