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

Re: exit trap and list pipelines



On Nov 9,  9:36pm, Anthony Heading wrote:
}
} Printing '6' here seems wrong?  I think it didn't some years back.
} 
} % zsh -c 'trap "echo hello" EXIT; { :; } | wc -c'
} 6
} hello

zsh-2.6 and zsh-3.0 yeild 0, zsh-4.3.17 prints 6.

The change occured because, where zsh formerly would note that the
right side was an external command and "exec" it (thereby disabling
the exit trap), newer zsh notices that there is a trap and does
another fork so that the trap can execute after wc finishes.  This
means that both sides of the pipe run the trap, whereas before
(and in bash) only one side does so.

However, in the older zsh case, there were circumstances in which
the trap did not execute *at all*.

commit 261193a5b7da4ba36ca146424b000aca27c69235
Author: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxx>
Date:   Fri Mar 30 16:51:54 2001 +0000

    Fix problem with traps not runing if shell exec'd final command

(workers/13851)



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