about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/contrib.yo4
-rw-r--r--Functions/Exceptions/catch2
-rw-r--r--Functions/Exceptions/throw5
4 files changed, 12 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 58d6eebb4..85e353993 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-09-28  Peter Stephenson  <pws@csr.com>
+
+	* 21779: Doc/Zsh/contrib.yo, Functions/Exceptions/throw, plus
+	unposted Functions/Exceptions/catch: improvements from Bart in
+	users/9452 plus clarifications to documentation.
+
 2005-09-28  Clint Adams  <clint@zsh.org>
 
 	* 21778: Completion/Debian/Command/_piuparts: completion for
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index a18910f75..f6b434c64 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -1284,8 +1284,8 @@ example({
 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
diff --git a/Functions/Exceptions/catch b/Functions/Exceptions/catch
index 5f3876228..6afd664da 100644
--- a/Functions/Exceptions/catch
+++ b/Functions/Exceptions/catch
@@ -28,7 +28,7 @@
 function catch {
   if [[ $TRY_BLOCK_ERROR -gt 0 && $EXCEPTION = ${~1} ]]; then
     (( TRY_BLOCK_ERROR = 0 ))
-    CAUGHT="$EXCEPTION"
+    typeset -g CAUGHT="$EXCEPTION"
     unset EXCEPTION
     return 0
   fi
diff --git a/Functions/Exceptions/throw b/Functions/Exceptions/throw
index a5478fb9c..5c7326999 100644
--- a/Functions/Exceptions/throw
+++ b/Functions/Exceptions/throw
@@ -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