Order of getopts parameters

Hi,
Does the order of argument and non-argument command line parameters matter to getopts?

with a getopts line in my script of
getopts p:cs opt

a command line of <script> -p 5 -s
only picks up the -p option, while <script> -s -p 5 picks up both.

Removing the space between the p and the argument doesn't help, nor does reordering the string in the getopts command.

I'm using Solaris 5, and ksh.

Thanks

Try the option and value without space.

 <script> -p5 -sString 

works fine for me...
test.ksh:

#!/bin/ksh
while getopts "p:cs" opt  ; do
        case $opt in
                p) echo opt-p: $OPTARG ;;
                c) echo opt-c ;;
                s) echo opt-s ;;
        esac
done
$ ./test.ksh -s -p 5
opt-s
opt-p: 5

Thanks for both responses, but as I said in my original post, removing the space doesn't help, and putting the no-arg option first works fine. It's putting the -s after the -p5 (or -p 5) that doesn't.
Subbeh, can you try running ./test.ksh -p 5 -s and see what you get?

Thanks.

Never mind. Subbeh's test script works for me when I reverse the order. It must be something else in my script.
I'll investigate further.

---------- Post updated at 02:06 PM ---------- Previous update was at 11:51 AM ----------

OK, my C programming knowledge was tripping me. I was putting "break"s at the end of each case, which of course took me right out of the "while" loop.
Anyway, thanks for playing.