summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-05-28 18:32:39 +0100
committerPeter Stephenson <pws@zsh.org>2015-05-28 18:32:39 +0100
commit2b08d0ed6747a4acf44b73068bfafc54ca1d0acf (patch)
tree6b2ef1ca29d0633ee231e6181a1b0d5e16356691 /Src/exec.c
parentcb596a55d921cb638a3cf0ede3ee60ae13728c10 (diff)
downloadzsh-2b08d0ed6747a4acf44b73068bfafc54ca1d0acf.tar.gz
zsh-2b08d0ed6747a4acf44b73068bfafc54ca1d0acf.zip
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.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 527d61197..9f163a627 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4910,9 +4910,11 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
if (!(flags & PM_UNDEFINED))
scriptname = dupstring(name);
oldzoptind = zoptind;
- zoptind = 1;
oldoptcind = optcind;
- optcind = 0;
+ if (!isset(POSIXBUILTINS)) {
+ zoptind = 1;
+ optcind = 0;
+ }
/* We need to save the current options even if LOCALOPTIONS is *
* not currently set. That's because if it gets set in the *
@@ -5049,8 +5051,10 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
argzero = oargv0;
}
pparams = pptab;
- optcind = oldoptcind;
- zoptind = oldzoptind;
+ if (!isset(POSIXBUILTINS)) {
+ zoptind = oldzoptind;
+ optcind = oldoptcind;
+ }
scriptname = oldscriptname;
oflags = ooflags;