zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: dana <dana@dana.is>
Cc: Zsh hackers list <zsh-workers@zsh.org>, franciscodezuviria@gmail.com
Subject: Re: [BUG] getopts OPTIND
Date: Wed, 14 Apr 2021 13:08:02 +0000	[thread overview]
Message-ID: <20210414130802.GF3882@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <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>
> 
> 


  parent reply	other threads:[~2021-04-14 13:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 16:22 Francisco de Zuviría Allende
2018-01-09 22:48 ` dana
2018-01-09 22:57   ` Bart Schaefer
2018-01-09 23:58     ` dana
2018-01-10  1:32       ` Francisco de Zuviría Allende
2018-01-10  9:05   ` Peter Stephenson
2021-04-13 23:28   ` dana
2021-04-14 13:04     ` [BUG] getopts OPTIND - yash's behaviour Daniel Shahaf
2021-04-14 13:08     ` Daniel Shahaf [this message]
2021-04-18  5:16       ` [BUG] getopts OPTIND dana
2021-04-20 21:31         ` Daniel Shahaf
2021-05-03 23:38           ` dana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210414130802.GF3882@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=dana@dana.is \
    --cc=franciscodezuviria@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).