Package: bash
Version: 3.1dfsg-8
Severity: wishlist

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* so that 
function's parameter parsing is independent.

Current behavior:
function1 -p x -f y #parameters parsed correctly
function2 -g j -d l #no parameters detected

This is because OPTIND is a global variable modified by function1 during 
parameter parsing.

Desired behavior: both functions get parameters parsed.

Workaround:
At the beginning of the function put "local OPTIND=1".

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-k7
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages bash depends on:
ii  base-files             4                 Debian base system miscellaneous f
ii  debianutils            2.17              Miscellaneous utilities specific t
ii  libc6                  2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii  libncurses5            5.5-5             Shared libraries for terminal hand

bash recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to