mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-07-04 02:21:25 +02:00
50351: "functions -c" can set signal traps
This commit is contained in:
parent
c36068357b
commit
d24ab95469
2 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
2022-06-09 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 50351: Src/builtin.c: "functions -c" can set signal traps
|
||||
|
||||
2022-06-09 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||
|
||||
* 50342: Src/jobs.c, Test/A05execution.ztst: fix test added by
|
||||
|
|
|
@ -3274,6 +3274,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
|
|||
|
||||
if (OPT_ISSET(ops,'c')) {
|
||||
Shfunc newsh;
|
||||
char *s = argv[1];
|
||||
if (!*argv || !argv[1] || argv[2]) {
|
||||
zwarnnam(name, "-c: requires two arguments");
|
||||
return 1;
|
||||
|
@ -3305,7 +3306,21 @@ bin_functions(char *name, char **argv, Options ops, int func)
|
|||
newsh->redir->nref++;
|
||||
if (shf->sticky)
|
||||
newsh->sticky = sticky_emulation_dup(sticky, 0);
|
||||
shfunctab->addnode(shfunctab, ztrdup(argv[1]), &newsh->node);
|
||||
/* is newsh a signal trap? (adapted from exec.c) */
|
||||
if (!strncmp(s, "TRAP", 4)) {
|
||||
int signum = getsignum(s + 4);
|
||||
if (signum != -1) {
|
||||
if (settrap(signum, NULL, ZSIG_FUNC)) {
|
||||
freeeprog(newsh->funcdef);
|
||||
dircache_set(&newsh->filename, NULL);
|
||||
zfree(newsh, sizeof(*newsh));
|
||||
return 1;
|
||||
}
|
||||
/* Remove any old node explicitly */
|
||||
removetrapnode(signum);
|
||||
}
|
||||
}
|
||||
shfunctab->addnode(shfunctab, ztrdup(s), &newsh->node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue