diff options
author | Peter Stephenson <p.stephenson@samsung.com> | 2018-05-17 09:32:26 +0100 |
---|---|---|
committer | Peter Stephenson <p.stephenson@samsung.com> | 2018-05-17 09:32:26 +0100 |
commit | ee7dda7806db51016f9fe8d84f7ac3edb594eff0 (patch) | |
tree | d2c109fd251ff291a673ed548a23bece8459bf81 | |
parent | b066cc3ea99fbb2d5b2c5882d17a679c52f2114b (diff) | |
download | zsh-ee7dda7806db51016f9fe8d84f7ac3edb594eff0.tar.gz zsh-ee7dda7806db51016f9fe8d84f7ac3edb594eff0.tar.xz zsh-ee7dda7806db51016f9fe8d84f7ac3edb594eff0.zip |
42785: Allow redefining math function to work silently.
Previously it failed with an error message that the function was already defined. This is inconsistent with most other aspects of shell usage.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/builtin.c | 13 |
2 files changed, 9 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog index deac58d68..e6e1427f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-05-17 Peter Stephenson <p.stephenson@samsung.com> + + * 42785: Src/builtins.c: redefining a user math function should + silently work as with redefining other shell objects. + 2018-05-14 Peter Stephenson <p.stephenson@samsung.com> * 42297: dana: Src/params.c, Test/D06subscript.ztst: (e) diff --git a/Src/builtin.c b/Src/builtin.c index 931605c6e..1cba97dec 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3199,7 +3199,7 @@ bin_functions(char *name, char **argv, Options ops, int func) pflags |= PRINT_NAMEONLY; if (OPT_MINUS(ops,'M') || OPT_PLUS(ops,'M')) { - MathFunc p, q; + MathFunc p, q, prev; /* * Add/remove/list function as mathematical. */ @@ -3331,15 +3331,10 @@ bin_functions(char *name, char **argv, Options ops, int func) p->maxargs = maxargs; queue_signals(); - for (q = mathfuncs; q; q = q->next) { + for (q = mathfuncs, prev = NULL; q; prev = q, q = q->next) { if (!strcmp(q->name, funcname)) { - unqueue_signals(); - zwarnnam(name, "-M %s: function already exists", - funcname); - zsfree(p->name); - zsfree(p->module); - zfree(p, sizeof(struct mathfunc)); - return 1; + removemathfunc(prev, q); + break; } } |