Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

exec last command in last pipeline.



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



Messages sorted by: Reverse Date, Date, Thread, Author