summaryrefslogtreecommitdiff
path: root/bin/ksh
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-12-15 05:25:53 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-12-15 05:25:53 +0000
commite7f2116d7cd5e75f1df5bf99d6617a92309a5466 (patch)
treec6ccb26eb23529bf4fd41e60c47fd5cef2c3f906 /bin/ksh
parent83964a8023035a984378b8b87ff611c09c3e1e6c (diff)
Unbreak parameter assignment when calling bourne style functions;
resolves PR 2450. ok deraadt@ millert@
Diffstat (limited to 'bin/ksh')
-rw-r--r--bin/ksh/exec.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index 995a8a2df9f..0989dc2b095 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.30 2003/11/10 21:26:39 millert Exp $ */
+/* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/*
* execute command tree
@@ -459,6 +459,7 @@ comexec(t, tp, ap, flags)
int type_flags;
int keepasn_ok;
int fcflags = FC_BI|FC_FUNC|FC_PATH;
+ int bourne_function_call = 0;
#ifdef KSH
/* snag the last argument for $_ XXX not the same as at&t ksh,
@@ -548,9 +549,10 @@ comexec(t, tp, ap, flags)
newblock();
/* ksh functions don't keep assignments, POSIX functions do. */
if (keepasn_ok && tp && tp->type == CFUNC
- && !(tp->flag & FKSH))
+ && !(tp->flag & FKSH)) {
+ bourne_function_call = 1;
type_flags = 0;
- else
+ } else
type_flags = LOCAL|LOCAL_COPY|EXPORT;
}
if (Flag(FEXPORT))
@@ -567,6 +569,8 @@ comexec(t, tp, ap, flags)
shf_flush(shl_out);
}
typeset(cp, type_flags, 0, 0, 0);
+ if (bourne_function_call && !(type_flags & EXPORT))
+ typeset(cp, LOCAL|LOCAL_COPY|EXPORT, 0, 0, 0);
}
if ((cp = *ap) == NULL) {