zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] getopts OPTIND
@ 2018-01-09 16:22 Francisco de Zuviría Allende
  2018-01-09 22:48 ` dana
  0 siblings, 1 reply; 12+ messages in thread
From: Francisco de Zuviría Allende @ 2018-01-09 16:22 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 934 bytes --]

testfunc() {
    echo $*;
    echo "OPTIND is $OPTIND, `(shift "$(($OPTIND - 1))"; echo next $1)`";
    echo 'I do getopts :a: varname'; getopts ':a:' varname;
    echo "OPTIND is $OPTIND, `(shift "$(($OPTIND - 1))"; echo next $1)`";
    echo 'I do getopts :a: varname'; getopts ':a:' varname;
    echo "OPTIND is $OPTIND, `(shift "$(($OPTIND - 1))"; echo next $1)`";
    echo 'I do getopts :a: varname'; getopts ':a:' varname;
    echo "OPTIND is $OPTIND, `(shift "$(($OPTIND - 1))"; echo next $1)`";
}

(testfunc -a -w -e -r -a)

Execution in bash:

-a -w -e -r -a
OPTIND is 1, next -a
I do getopts :a: varname
OPTIND is 3, next -e
I do getopts :a: varname
OPTIND is 4, next -r
I do getopts :a: varname
OPTIND is 5, next -a

execution in zsh:

-a -w -e -r -a
OPTIND is 1, next -a
I do getopts :a: varname
OPTIND is 3, next -e
I do getopts :a: varname
OPTIND is 3, next -e
I do getopts :a: varname
OPTIND is 4, next -r

Best regards

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-05-03 23:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 16:22 [BUG] getopts OPTIND 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     ` [BUG] getopts OPTIND Daniel Shahaf
2021-04-18  5:16       ` dana
2021-04-20 21:31         ` Daniel Shahaf
2021-05-03 23:38           ` dana

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).