Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] getopts OPTIND
- X-seq: zsh-workers 48568
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: dana <dana@xxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>, franciscodezuviria@xxxxxxxxx
- Subject: Re: [BUG] getopts OPTIND
- Date: Wed, 14 Apr 2021 13:08:02 +0000
- Archived-at: <https://zsh.org/workers/48568>
- In-reply-to: <C8AAF10F-8FF7-47D6-8760-5960D62E91F7@dana.is>
- List-id: <zsh-workers.zsh.org>
- References: <CA++-COw=KgUBJc1PMq=L5be2VeJGXBjwtsRfRx7+7GSMspcQJQ@mail.gmail.com> <0877C4E8-4CA3-453F-A16B-99E576F60E8D@dana.is> <C8AAF10F-8FF7-47D6-8760-5960D62E91F7@dana.is>
dana wrote on Tue, Apr 13, 2021 at 18:28:50 -0500:
> (Resurrecting this per workers/48509)
>
> bin_getopts() has changed a little since i posted my patch before, this looks
> a bit weirder. The test is also weird. But i confirmed that this makes it
> behave like dash, bash, and mksh (my ksh93 doesn't support local, and i still
> don't know what yash is doing):
>
> % pbpaste | zsh-dev -f
> <1><1><3><5><7><6>
> % pbpaste | zsh-dev -f --posix-builtins
> <2><2><3><6><7><7>
> % pbpaste | dash
> <2><2><3><6><7><7>
> % pbpaste | bash
> <2><2><3><6><7><7>
> % pbpaste | mksh
> <2><2><3><6><7><7>
> % pbpaste | yash
> <3><3><3><7><7><7>
>
> tbh i don't think i fully understand why this needs to work this way, or
> whether there are other cases that should be tested. Open to review obv
Should the descriptions of OPTIND and/or POSIX_BUILTINS in the manual be
extended as well? (Once the behaviour is decided on, if there are still
open questions about that.)
Some more cases to test:
.
t 0
t 1 foo
t 1 -- foo
t 1 -b
.
where -b doesn't take an argument.
> @@ -96,3 +96,29 @@
> + # Try all these the native way, then the POSIX_BUILTINS way
> + for 1 in no_posix_builtins posix_builtins; do (
> + setopt $1
> + print -rn - "$1: "
> + t 1 -a
> + t 1 -w
> + t 2 -a -w
> + t 4 -a -w -e -r -a
> + t 5 -a -w -e -a -w -e
> + t 5 -a -w -e -r -ax -a
> + print
> + ); done
> +0:OPTIND calculation with and without POSIX_BUILTINS (workers/42248)
> +>no_posix_builtins: <1><1><3><5><7><6>
> +>posix_builtins: <2><2><3><6><7><7>
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author