Can not test many arguments

I'm writing a shell script with bash ver 2.05b in linux. My script has a test with 5 arguments like this:

until [ $grade == 'SSK' -o $grade == 'HSK' -o $grade == 'SK' -o $grade == 'SMSK' -o $grade == 'UNSK' ]
do
.....(some codes)
done

but it raise an error:
[: too many arguments

I tried some ways but not ok.
Could you give a way to work around this. Thanks :confused:

Hi baton,

instead of that try this one:

until [[ (${grade} == 'SSK') || (${grade} == 'HSK') || (${grade} == 'SK') || (${grade} == 'SMSK') || (${grade} == 'UNSK')]]
do
.....(some codes)
done

It works, thanks Niyati. A little curious, why we have to use [[ instead of [ in test expression. Is there any special meaning here?.

Thanks so much.
Baton

Hi Baton,

Sometimes single [ doesn't work with this many conditions. Normally it works but i have faced issue sometime, so to be on safer side i always use [[ in any condition.

You might want to check the man pages. See the following in bold.
From man ksh

       [[ expression ]]
              Similar to the test and [ ... ] commands (described later), with
              the following exceptions:
                �    Field splitting and file name  generation  are  not  per-
                     formed on arguments.
                �    The  -a  (and) and -o (or) operators are replaced with &&
                     and ||, respectively.
                �    Operators (e.g., -f, =, !, etc.) must be unquoted.
                �    The second operand of != and = expressions  are  patterns
                     (e.g., the comparison in
                                        [[ foobar = f*r ]]
                     succeeds).
                �    There  are two additional binary operators: < and > which
                     return true if their first string operand is  less  than,
                     or  greater  than,  their  second string operand, respec-
                     tively.
                �    The single argument form of  test,  which  tests  if  the
                     argument  has  non-zero  length,  is not valid - explicit
                     operators must be always be used, e.g., instead of
                                              [ str ]
                     use
                                           [[ -n str ]]
                �    Parameter, command and arithmetic substitutions are  per-
                     formed  as  expressions are evaluated and lazy expression
                     evaluation is used for the &&  and  ||  operators.   This
                     means that in the statement
                                  [[ -r foo && $(< foo) = b*r ]]
                     the  $(<  foo)  is  evaluated if and only if the file foo
                     exists and is readable.