Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
More fake exec
- X-seq: zsh-workers 1809
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hacking and development)
- Subject: More fake exec
- Date: Mon, 29 Jul 1996 04:07:44 +0200 (MET DST)
I've just discovered that zsh -c '{ something }' does not do a fake exec.
man_db calls the pager this way which means an extra process is necessary
for each man. I thought that there was a time when zsh did a fake exec
here but it seems that it never did. I think that the patch below does not
break anything while trying to do a fake exec whenever possible: in the
last element of a for loop, in the body of an if statement and in a case
statement and of course in a { ... }. As I remember Peter mentioned that
he experimented with something similar. I do not see anything wrong with
that.
Zoltan
*** Src/loop.c 1996/06/28 02:05:24 2.1
--- Src/loop.c 1996/07/29 01:45:43
***************
*** 55,61 ****
while ((str = (char *)ugetnode(args))) {
setsparam(node->name, ztrdup(str));
list = (List) dupstruct(node->list);
! execlist(list, 1, 0);
if (breaks) {
breaks--;
if (breaks || !contflag)
--- 55,61 ----
while ((str = (char *)ugetnode(args))) {
setsparam(node->name, ztrdup(str));
list = (List) dupstruct(node->list);
! execlist(list, 1, (cmd->flags & CFLAG_EXEC) && empty(args));
if (breaks) {
breaks--;
if (breaks || !contflag)
***************
*** 261,267 ****
noerrexit = olderrexit;
if (*t)
! execlist(*t, 1, 0);
else
lastval = 0;
--- 261,267 ----
noerrexit = olderrexit;
if (*t)
! execlist(*t, 1, cmd->flags & CFLAG_EXEC);
else
lastval = 0;
***************
*** 302,308 ****
l++;
}
if (*l)
! execlist(*l, 1, 0);
}
return lastval;
}
--- 302,308 ----
l++;
}
if (*l)
! execlist(*l, 1, cmd->flags & CFLAG_EXEC);
}
return lastval;
}
*** Src/exec.c 1996/07/26 18:48:24 2.75
--- Src/exec.c 1996/07/29 01:45:42
***************
*** 1584,1594 ****
if (is_exec)
entersubsh(how, type != SUBSH ? 2 : 1, 1);
if (type >= CURSH) {
! static int (*func[]) _((Cmd)) =
! {
execcursh, exectime, execfuncdef, execfor, execwhile,
! execrepeat, execif, execcase, execselect, execcond};
lastval = (func[type - CURSH]) (cmd);
} else if (is_builtin || is_shfunc) {
LinkList restorelist = 0, removelist = 0;
--- 1584,1596 ----
if (is_exec)
entersubsh(how, type != SUBSH ? 2 : 1, 1);
if (type >= CURSH) {
! static int (*func[]) _((Cmd)) = {
execcursh, exectime, execfuncdef, execfor, execwhile,
! execrepeat, execif, execcase, execselect, execcond
! };
+ if (last1 == 1)
+ cmd->flags |= CFLAG_EXEC;
lastval = (func[type - CURSH]) (cmd);
} else if (is_builtin || is_shfunc) {
LinkList restorelist = 0, removelist = 0;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author