I wrote a script that uses getopts and it works fine. However, I would like to put the function in that script in a startup file (.kshrc or .profile). I took the "main" portion of the script and made it a function in the startup script. I source the startup script but it doesn't seem to parse through the getopts case.
So my question is if using getopts in a function is even valid?
One function I'll call hctinfo() and it is considered by me to be the "main" part of my set of functions. It calls other functions depending on the options (handled by getopts.
The first time I log in to the system and source the file that has the functtions define and run it, it works. Each subsequent time I attempt to run it it fails to parse the options.
$ . ./.bashrc
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
\nWorking directory is /dvs/dncs\nDatabase is dncsdb\n
[14:00:22]$ hctinfo -a 00:40:7B:E1:AB:66
ADMIN_STAT=1
Deployed
[14:00:26]$ hctinfo -a 00:40:7B:E1:AB:66
[14:00:32]$
I think I know what the problem is...
Somehow the options, options count, etc... (everything associated with getopts) needs to get reset.