Package: bash
Version: 5.1-2+b2
Severity: important

Dear maintainer,

With bash 5.1-2+b2, the output of

getopts abc opt hello; EC=$?; echo $opt $OPTIND $EC

is

x 2 1

$EC == 1 is correct, $opt == x is strange but irrelevant, but $OPTIND == 2 is
not the
index of the first non-option arg, the correct value is 1.
This corrupts all my scripts which use shift $((OPTIND - 1)) to process the
non-option args.

After downgrading to bash 5.0-4, the output of the above command is

x 1 1

as it should be.


-- System Information:
Debian Release: 11.0
  APT prefers testing
  APT policy: (800, 'testing'), (700, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-7-amd64 (SMP w/2 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE,
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not
set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages bash depends on:
ii  base-files   11.1
ii  debianutils  4.11.2
ii  libc6        2.31-12
ii  libtinfo6    6.2+20201114-2

Versions of packages bash recommends:
ii  bash-completion  1:2.11-2

Versions of packages bash suggests:
pn  bash-doc  <none>

Reply via email to