From 2b08d0ed6747a4acf44b73068bfafc54ca1d0acf Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 28 May 2015 18:32:39 +0100 Subject: 35318: POSIX_BUILTINS behaviour for getopts. It needs to keep OPTIND, as well as the index within the string pointed to by OPTIND, global in this case. --- Doc/Zsh/builtins.yo | 3 ++- Doc/Zsh/options.yo | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'Doc/Zsh') diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index a2c03bcc4..f8e4edf91 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -866,7 +866,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 reset to tt(1) upon exit from a shell function. tt(OPTARG) +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) 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 032423def..4c0ae122f 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -2038,6 +2038,10 @@ tt(unset). In addition, various error conditions associated with the above builtins or tt(exec) cause a non-interactive shell to exit and an interactive shell to return to its top-level processing. + +Furthermore, the tt(getopts) builtin behaves in a POSIX-compatible +fashion in that the associated variable tt(OPTIND) is not made +local to functions. ) pindex(POSIX_IDENTIFIERS) pindex(NO_POSIX_IDENTIFIERS) -- cgit 1.4.1