From c23a0d84b029676832ea0f2eeb0caa8c47d0500d Mon Sep 17 00:00:00 2001 From: dana Date: Mon, 3 May 2021 18:08:11 -0500 Subject: 48614: getopts: Calculate OPTIND according to POSIX_BUILTINS --- Doc/Zsh/builtins.yo | 3 ++- Doc/Zsh/options.yo | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Doc') diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 61dc6986f..022921bfa 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -982,7 +982,8 @@ vindex(OPTARG, use of) The first option to be examined may be changed by explicitly assigning to tt(OPTIND). tt(OPTIND) has an initial value of tt(1), and is normally set to tt(1) upon entry to a shell function and restored -upon exit (this is disabled by the tt(POSIX_BUILTINS) option). tt(OPTARG) +upon exit. (The tt(POSIX_BUILTINS) option disables this, and also changes +the way the value is calculated to match other shells.) tt(OPTARG) is not reset and retains its value from the most recent call to tt(getopts). If either of tt(OPTIND) or tt(OPTARG) is explicitly unset, it remains unset, and the index or option argument is not diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 6e862fae8..546b16b65 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -2249,7 +2249,8 @@ command found in the path. Furthermore, the tt(getopts) builtin behaves in a POSIX-compatible fashion in that the associated variable tt(OPTIND) is not made -local to functions. +local to functions, and its value is calculated differently to match +other shells. Moreover, the warning and special exit code from tt([[ -o )var(non_existent_option)tt( ]]) are suppressed. -- cgit 1.4.1