Bypass getopts errors and continue processing?

Is there a way to do this?

while getopts "n:g:m:i:p:d:a:" OPTION
do
   case $OPTION in
...

if i do a ./script.sh -n john -u user -p password, it will output:

 name= john
./script.sh: illegal option -- u

Is there a way to skip over errors so that -p will get processed as well?

By the way, ./script.sh -n john -u -p password will output:

name=john
password=password
./script.sh: illegal option --u

so I'm guessing the option with -u is the problem?

Why don't you just add 'u:' to getopts?

while getopts "n:g:m:i:u:d:a:" OPTION

Please when asking about shell programming specify your system, the first line of your script, shell you use, version of your shell, and give a working (or not working but full) example of your script.

I don't want a -u. And also, i'd want to handle cases where the user might input a wrong parameter with an option...

Are you saying you want to print a nice error message when the user enters an invalid option?

no, it already does print an error message, but it doesn't continue processing the rest of the arguments after the error...

I'd suggest that the script should exit if the user enters an invalid option.

However, I can think of a way around this.

---------- Post updated at 09:20 AM ---------- Previous update was at 09:11 AM ----------

Try this:
add the ':' at the begining of getopts.
add ?) to the case statement and do what you want in there.

while getopts ":dhqTv" OPT                              # While there is a command line option
do
   case $OPT in
      d)   
           ;;

      h)   print_options;;

      q)   
           ;;

      T)  
           ;;

      v)   
           ;;

      ?)   print_status_message "ERROR: Unknown flag encountered.\n" ERROR

           ;;

   esac
done                                            # end -

well what I want to do is continue processing the rest of the parameters instead of exiting the script...not sure how to do that