• fix an inverted logic bug in the test I wrote

• only trigger deleting an alias in favour of a function for “()”, not
  just the opening parenthesis: “stop( )” is not a function definition
  (well, actually it seems to be, but… not according to POSIX, anyway)
• defer dropping the alias until the function is actually defined (õÕ)
This commit is contained in:
tg
2011-05-07 00:51:12 +00:00
parent c38dfbf51a
commit 40e914e8a5
4 changed files with 16 additions and 17 deletions

13
exec.c
View File

@@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.90 2011/04/17 15:40:35 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.91 2011/05/07 00:51:11 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@@ -962,11 +962,20 @@ findfunc(const char *name, uint32_t h, bool create)
int
define(const char *name, struct op *t)
{
uint32_t nhash;
struct tbl *tp;
bool was_set = false;
nhash = hash(name);
if (t != NULL && !tobool(t->u.ksh_func)) {
/* drop same-name aliases for POSIX functions */
if ((tp = ktsearch(&aliases, name, nhash)))
ktdelete(tp);
}
while (/* CONSTCOND */ 1) {
tp = findfunc(name, hash(name), true);
tp = findfunc(name, nhash, true);
if (tp->flag & ISSET)
was_set = true;