ARGV and ARGC in bash 3 and bash 3.2

Hi Folks,

I've prepared a shell script that takes action based on arguments and number of arguments..sample code like:

ARGV=("$@")
ARGC=("$#")

case ${ARGV[1]} in 

abc) 
      if [ $ARGC -eq 3 ]; then
      ......
      else
           printf  "\nInvalid number of arguments, please check the inputs and try again\n"
fi;;

efg) ... and so on

Now the issue is that I wrote and run that script successfully in bash 3.2 on Max OSX. But when tried to run the same on bash 3 on Solaris it gives error and stop:

'ARGV=' unexpected

I was wondering how the script ran successfully on bash 3.2 and what piece i m missing here to get it work on bash 3?

Really appreciate your help.

Thanks and Regards,
SBC

Not a bash guy, just a man page reader: Man Page for bash (All Section 1) - The UNIX and Linux Forums

ARGC is not an array, why use ()?

Did you 'declare -a ARGV' to tell bash it is an array? Maybe the later bash assumes you meant that. Later stuff is like that.

Seems silly, maybe AR, :D, why not:

while [ $# != 0 ]
do
case "$1" in
(abc)
  ...
  ;;
(efg)
  ...
  ;;
esac
shift
done

PS: Use both () in case cases so % in vi still works.

Thanks for the response DG, yes I already tried declaring the arrays explicitly but it didnt work. Would like to understand the difference what else could be the issue?