options: Always reset OPTIND in getoptsreset
commitc4a9b31b9b4b0adc6e0ad9352126fc4bea0bc2a7
authorHerbert Xu <herbert@gondor.apana.org.au>
Sun, 19 May 2024 14:21:42 +0000 (19 22:21 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 26 May 2024 10:21:09 +0000 (26 18:21 +0800)
treeb0c211bd292d7ca747d0b6a2cc02d200baca0e80
parent8f158f6375cbca0061d1d08f3571fef9fd17678d
options: Always reset OPTIND in getoptsreset

Always reset OPTIND if it is modified by the user, regardless of
its value.

Do not call getoptsreset when returning from a function because
of "local OPTIND" as this simply trashes the caller's getopts
state.

Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
src/options.c
src/var.c