zsh-workers
 help / color / mirror / code / Atom feed
From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: pws@ifh.de (Peter Stephenson)
Cc: zsh-workers@math.gatech.edu (Zsh workers list)
Subject: Re: Odd behavior of "trap" and "functions" in 3.0-pre2
Date: Fri, 26 Jul 1996 13:56:21 +0200 (MET DST)	[thread overview]
Message-ID: <199607261156.NAA04201@bolyai.cs.elte.hu> (raw)
In-Reply-To: <199607260808.KAA09932@hydra.ifh.de> from Peter Stephenson at "Jul 26, 96 10:08:34 am"

> schaefer@candle.brasslantern.com wrote:
> > zagzig<14> trap "echo foo" USR2
> > zagzig<17> grep TRAP <<(functions)
> > TRAPALRM () {
> > zagzig<18>
> > 
> > I'm almost certain that `functions` used to list all the TRAPxxx ....
> 
> Looks like the `trap' form of traps don't handle functions properly,
> while the TRAPxxx functions do handle traps properly, so this is
> certainly a mistake.  It seems the bin_trap() end of things got missed
> out in some reorganisation.
> 
> I've tried to write this in such away as to maintain symmetry between
> settrap() and unsettrap().  They now have a final argument which is
> set to 1 if they should set/unset the corresponding function.  This is
> necessary because the function code needs to be able to do its own
> separate manipulations on the function.  The rule is therefore that
> any call from outside the function-handling code should set the last
> argument to 1 to maintain parallel trap/TRAPxxx settings.
> 
> Note there's no memory leak in the second last hunk:  the function,
> the command list, and the name all needed to be separately allocated.
> 
> I fixed a related bug:
> 
> % TRAPUSR1() { }
> % trap
> TRAPUSR1() {}
> 
> When defining the function, you now need the space between the braces

I've mostly rewritten most of the thing related to traps which fixed all of
these bugs you describe above.  Sorry for the duplicate work.  In pre4
traps defined by trap and TRAPxxx functions will be different.  trap will
be POSIX compatible.  It will not define any function and it executes the
trap in the current environment.  TRAPxxx functions will work as before.
Also traps set by trap will be unset in a subshell as required by POSIX but
this does not affect the TRAPxxx functions.  This is only done with
explicit subshells and with backgrounded commands, so trap | less still
works (in bash/ksh trap | less shows nothing).  This is legal since POSIX
does not tell wether a pipe element should be executed in a subshell or in
the current shell environment.  In fact I've already put together pre4 and
put in onto the ftp site yesterday.  Then I went home and I wanted to post
the announcement with my modem but then I discovered a bug in this new trap
implementation ...  So even if you see pre4 on an ftp site, do not download
it, it is not the final version.  The final pre4 will be ready within a few
hours.

Zoltan



      parent reply	other threads:[~1996-07-26 12:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-06 19:09 Bart Schaefer
1996-07-26  8:08 ` Peter Stephenson
1996-07-26  8:15   ` Printing blank funcion Peter Stephenson
1996-07-26 11:56   ` Zoltan Hidvegi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199607261156.NAA04201@bolyai.cs.elte.hu \
    --to=hzoli@cs.elte.hu \
    --cc=pws@ifh.de \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).