From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1) Description of problem: It is a documented behaviour but not what the user(me) expects. I have 2 complex functions that do parameter parsing with the getopts built-in command. OPTIND is used to keep the number of next parameter to parse. It is reset to 1 whenever a new shell is invoked. I makes more sense to be reset to 1 *for the function* when called so that function's parameter parsing is independent. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: function1 -p x -f y #parameters parsed correctly function2 -g j -d l #no parameters detected Actual Results: function1 - parameters parsed correctly function2 - no parameters detected This is because OPTIND is a global variable modified by function1 during parameter parsing. Expected Results: both functions have parameters parsed correctly Additional info: workaround: At the beginning of the function put "local OPTIND=1".
What are you expecting it *is* documented behavior?
That is a feature request. I can't see any sense in current behavior. Or will you point me to the bash bug tracking system if any?
This bug is filed against RHEL 3, which is in maintenance phase. During the maintenance phase, only security errata and select mission critical bug fixes will be released for enterprise products. Since this bug does not meet that criteria, it is now being closed. For more information of the RHEL errata support policy, please visit: http://www.redhat.com/security/updates/errata/ If you feel this bug is indeed mission critical, please contact your support representative. You may be asked to provide detailed information on how this bug is affecting you.