zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: About zsh-users 8489 (exception handling)
Date: Wed, 28 Sep 2005 16:19:29 +0100	[thread overview]
Message-ID: <20050928161929.726e31e6.pws@csr.com> (raw)
In-Reply-To: <1050928024249.ZM23758@candle.brasslantern.com>

Bart Schaefer <schaefer@brasslantern.com> wrote:
> I think EXCEPTION should also be declared with "typeset -g", so that
> makes the complete function look like:
> 
> throw() {
>   typeset -g EXCEPTION="$1"
>   readonly THROW
>   if (( TRY_BLOCK_ERROR == 0 )); then
>     # We are throwing an exception from the middle of an always-block.
>     # We can do this by restoring the error status from the try-block.
>     # (I am not convinced I ever intended this to work, but it does...)
>     (( TRY_BLOCK_ERROR = 1 ))
>   fi
>   # Raise an error, but don't show an error message.
>   # This is a bit of a hack.  (Surprised?)
>   THROW= 2>/dev/null
> }

How about this...

Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.47
diff -u -r1.47 contrib.yo
--- Doc/Zsh/contrib.yo	22 Sep 2005 22:23:45 -0000	1.47
+++ Doc/Zsh/contrib.yo	28 Sep 2005 15:16:36 -0000
@@ -1284,8 +1284,8 @@
 In common with exception handling in other languages, the exception may be
 thrown by code deeply nested inside the `try' block.  However, note that it
 must be thrown inside the current shell, not in a subshell forked for a
-pipline, parenthesised current-shell construct, or some form of
-substitution.
+pipeline, parenthesised current-shell construct, or some form of
+command or process substitution.
 
 The system internally uses the shell variable tt(EXCEPTION) to record the
 name of the exception between throwing and catching.  One drawback of this
Index: Functions/Exceptions/throw
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Exceptions/throw,v
retrieving revision 1.1
diff -u -r1.1 throw
--- Functions/Exceptions/throw	15 Feb 2005 18:32:38 -0000	1.1
+++ Functions/Exceptions/throw	28 Sep 2005 15:16:36 -0000
@@ -19,11 +19,12 @@
 # script.
 
 # The following must not be local.
-EXCEPTION="$1"
+typeset -g EXCEPTION="$1"
+readonly THROW
 if (( TRY_BLOCK_ERROR == 0 )); then
   # We are throwing an exception from the middle of an always-block.
   # We can do this by restoring the error status from the try-block.
   (( TRY_BLOCK_ERROR = 1 ))
 fi
 # Raise an error, but don't show an error message.
-{ ${:?THROW} } 2>/dev/null
+THROW= 2>/dev/null



-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


       reply	other threads:[~2005-09-28 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20050927234726.GC988@DervishD>
     [not found] ` <1050928024249.ZM23758@candle.brasslantern.com>
2005-09-28 15:19   ` Peter Stephenson [this message]
2005-09-29 10:31     ` DervishD
2005-09-29 10:42       ` Peter Stephenson

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=20050928161929.726e31e6.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /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).