Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.bugs.dist > #1197919
| From | Herbert Xu <herbert@gondor.apana.org.au> |
|---|---|
| Newsgroups | linux.debian.bugs.dist |
| Subject | Bug#985478: [PATCH] options: Always reset OPTIND in getoptsreset |
| Date | 2024-05-19 14:10 +0200 |
| Message-ID | <IFNwt-epeQ-7@gated-at.bofh.it> (permalink) |
| References | (5 earlier) <IFNwt-epeQ-19@gated-at.bofh.it> <IFNwt-epeQ-21@gated-at.bofh.it> <IFNwt-epeQ-23@gated-at.bofh.it> <BUchj-4ca-1@gated-at.bofh.it> <IFNwt-epeQ-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed, Jan 04, 2023 at 04:50:34PM +0000, Harald van Dijk wrote:
>
> Personally, I do think it is better if shells allow assigning arbitrary
> values to OPTIND, including unsetting it, and only have the getopts command
> raise an error if the value is non-numeric, but that is my personal opinion
> and I don't see much of a problem if dash decides to go the other way,
> unless POSIX makes it explicit that it is not permitted for shells to do
> this. FWIW, I did make that change for my version, <https://github.com/hvdijk/gwsh/commit/0df0ba33748eb3881b07cb724fd4fa54422ef2bc>,
> if that change is desired for dash it is easy to apply.
I've decided to make getoptsreset always do the reset, regardless
of the value of OPTIND. Why else would you assign it anyway?
---8<---
Always reset OPTIND if it is modified by the user, regardless of
its value.
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/src/options.c b/src/options.c
index 4d0a53a..c74e4fe 100644
--- a/src/options.c
+++ b/src/options.c
@@ -393,7 +393,7 @@ setcmd(int argc, char **argv)
void getoptsreset(const char *value)
{
- shellparam.optind = number(value) ?: 1;
+ shellparam.optind = 1;
shellparam.optoff = -1;
}
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Back to linux.debian.bugs.dist | Previous | Next — Next in thread | Find similar | Unroll thread
Bug#985478: [PATCH] options: Always reset OPTIND in getoptsreset Herbert Xu <herbert@gondor.apana.org.au> - 2024-05-19 14:10 +0200
Bug#985478: [PATCH] options: Always reset OPTIND in getoptsreset Harald van Dijk <harald@gigawatt.nl> - 2024-05-19 15:40 +0200
Bug#985478: [v2 PATCH] options: Always reset OPTIND in getoptsreset Herbert Xu <herbert@gondor.apana.org.au> - 2024-05-19 16:30 +0200
Bug#985478: [v2 PATCH] options: Always reset OPTIND in getoptsreset наб <nabijaczleweli@nabijaczleweli.xyz> - 2024-05-21 16:50 +0200
csiph-web