* exec last command in last pipeline.
@ 1999-08-14 16:04 Tanaka Akira
1999-08-14 22:05 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Tanaka Akira @ 1999-08-14 16:04 UTC (permalink / raw)
To: zsh-workers
Z:akr@is27e1u11% zsh -frc 'exec echo a'
a
Z:akr@is27e1u11% zsh -fc 'exec > /dev/null'
zsh: redirection with no command
zsh: exit 1 zsh -fc 'exec > /dev/null'
Z:akr@is27e1u11% zsh -fc 'exec printenv SHLVL'
2
Z:akr@is27e1u11% zsh -c 'print $$; sh -c '\''echo $$; printenv SHLVL'\'''
9076
9076
2
Z:akr@is27e1u11%
I think they should be:
Z:akr@is27e1u11% zsh -frc 'exec echo a'
exec: echo: restricted
zsh: exit 1 zsh -frc 'exec echo a'
Z:akr@is27e1u11% zsh -fc 'exec > /dev/null'
Z:akr@is27e1u11% zsh -fc 'exec printenv SHLVL'
1
Z:akr@is27e1u11% zsh -c 'print $$; sh -c '\''echo $$; printenv SHLVL'\'''
9078
9078
1
Z:akr@is27e1u11%
Index: exec.c
===================================================================
RCS file: /projects/zsh/zsh/Src/exec.c,v
retrieving revision 1.1.1.19
diff -u -F^( -r1.1.1.19 exec.c
--- exec.c 1999/07/24 14:02:56 1.1.1.19
+++ exec.c 1999/08/14 15:55:32
@@ -1522,7 +1522,7 @@
/* Current shell should not fork unless the *
* exec occurs at the end of a pipeline. */
- if ((cflags & BINF_EXEC) && last1 == 2)
+ if ((cflags & BINF_EXEC) && last1)
flags |= CFLAG_EXEC;
/* Empty command */
@@ -2053,8 +2053,9 @@
restore_params(restorelist, removelist);
} else {
- if (flags & CFLAG_EXEC) {
+ if (!forked)
setiparam("SHLVL", --shlvl);
+ if (flags & CFLAG_EXEC) {
/* If we are exec'ing a command, and we are not *
* in a subshell, then save the history file. */
if (!subsh && isset(RCS) && interact && !nohistsave)
--
Tanaka Akira
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: exec last command in last pipeline.
1999-08-14 16:04 exec last command in last pipeline Tanaka Akira
@ 1999-08-14 22:05 ` Bart Schaefer
1999-08-15 6:12 ` Tanaka Akira
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 1999-08-14 22:05 UTC (permalink / raw)
To: zsh-workers
On Aug 15, 1:04am, Tanaka Akira wrote:
} Subject: exec last command in last pipeline.
}
} --- exec.c 1999/07/24 14:02:56 1.1.1.19
} +++ exec.c 1999/08/14 15:55:32
} @@ -1522,7 +1522,7 @@
}
} /* Current shell should not fork unless the *
} * exec occurs at the end of a pipeline. */
} - if ((cflags & BINF_EXEC) && last1 == 2)
} + if ((cflags & BINF_EXEC) && last1)
} flags |= CFLAG_EXEC;
}
} /* Empty command */
I'm extremely dubious of that change. The only way that last1 can be set
to 2 is here in execpline2():
if (pline->type == END)
execcmd(pline->left, input, output, how, last1 ? 1 : 2);
If you remove the test of last1 == 2 in execcmd(), there's no reason to
test for last1 in execpline2(). But both tests have been there since
before version 3.0.0; I'm concerned that the shell is going to exec in
some cases where it should not.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: exec last command in last pipeline.
1999-08-14 22:05 ` Bart Schaefer
@ 1999-08-15 6:12 ` Tanaka Akira
0 siblings, 0 replies; 3+ messages in thread
From: Tanaka Akira @ 1999-08-15 6:12 UTC (permalink / raw)
To: zsh-workers
In article <990814220530.ZM6932@candle.brasslantern.com>,
"Bart Schaefer" <schaefer@candle.brasslantern.com> writes:
> If you remove the test of last1 == 2 in execcmd(), there's no reason to
> test for last1 in execpline2(). But both tests have been there since
> before version 3.0.0; I'm concerned that the shell is going to exec in
> some cases where it should not.
if ((how & Z_ASYNC) || (!(flags & CFLAG_EXEC) &&
(((is_builtin || is_shfunc) && output) ||
(!is_cursh && (last1 != 1 || sigtrapped[SIGZERR] ||
sigtrapped[SIGEXIT] || havefiles()))))) {
and
if (last1 == 1)
(and
DPUTS(last1 != 1 && !forked, "BUG: not exiting?");
)
can be the reason to set last1 to 2 instead of 1.
--
Tanaka Akira
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-08-15 6:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-14 16:04 exec last command in last pipeline Tanaka Akira
1999-08-14 22:05 ` Bart Schaefer
1999-08-15 6:12 ` Tanaka Akira
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).