summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c4
-rw-r--r--Src/exec.c12
2 files changed, 12 insertions, 4 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index a9afb4540..18c22f29e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4713,6 +4713,10 @@ bin_shift(char *name, char **argv, Options ops, UNUSED(int func))
return ret;
}
+/*
+ * Position of getopts option within OPTIND argument with multiple options.
+ */
+
/**/
int optcind;
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;