Your message dated Thu, 21 Mar 2024 02:17:47 +0100
with message-id <[email protected]>
and subject line Re: Bug#990831: $OPTIND issue solved in bash 5.1-2+b3
has caused the Debian Bug report #990831,
regarding getopts: $OPTIND == 2 although no option arg supplied.
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
990831: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990831
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
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>
--- End Message ---
--- Begin Message ---
Version: 5.2.21-2
On Mon, 9 Aug 2021 21:53:09 +0200 kalle <[email protected]> wrote:
Dear maintainer,
With bash 5.1-2+b3, the output of
getopts abc opt hello; EC=$?; echo $opt $OPTIND $EC is
y 1 1
The value of $OPTIND is correct now.
But as already mentioned, $opt == x was strange, and the same holds for
$opt == y now.
The bash manual states that if the first non-option arg is encountered,
opt is set to ?,
so this is another bug.
Hi,
this issue seems fixed in bash 5.2.21-2:
$ getopts abc opt hello; EC=$?; echo $opt $OPTIND $EC
? 1 1
Please reopen this bug if you can still replicate this issue.
Regards,
--
Gioele Barabucci
--- End Message ---