zsh-workers
 help / color / mirror / code / Atom feed
* Re: About zsh-users 8489 (exception handling)
       [not found] ` <1050928024249.ZM23758@candle.brasslantern.com>
@ 2005-09-28 15:19   ` Peter Stephenson
  2005-09-29 10:31     ` DervishD
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2005-09-28 15:19 UTC (permalink / raw)
  To: zsh-workers

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.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: About zsh-users 8489 (exception handling)
  2005-09-28 15:19   ` About zsh-users 8489 (exception handling) Peter Stephenson
@ 2005-09-29 10:31     ` DervishD
  2005-09-29 10:42       ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: DervishD @ 2005-09-29 10:31 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

    Hi Peter :)

 * Peter Stephenson <pws@csr.com> dixit:
> How about this...
[Patch for throw]
    How about doing the same to "catch". It uses a global, too
(CAUGHT), so I think it's a good idea to "typeset -g" it.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: About zsh-users 8489 (exception handling)
  2005-09-29 10:31     ` DervishD
@ 2005-09-29 10:42       ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2005-09-29 10:42 UTC (permalink / raw)
  To: zsh-workers

DervishD wrote:
> [Patch for throw]
>     How about doing the same to "catch". It uses a global, too
> (CAUGHT), so I think it's a good idea to "typeset -g" it.

Yes, I committed that change when the suggestion came up.

pws


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-29 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20050927234726.GC988@DervishD>
     [not found] ` <1050928024249.ZM23758@candle.brasslantern.com>
2005-09-28 15:19   ` About zsh-users 8489 (exception handling) Peter Stephenson
2005-09-29 10:31     ` DervishD
2005-09-29 10:42       ` Peter Stephenson

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).