summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-09-28 15:26:44 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-09-28 15:26:44 +0000
commit81a331a3eaf81352b0f06a7b91f9ced73be04741 (patch)
tree62c9229d625c27e267441961d229bf8047792b27
parentc3ca181fbe299b0f61885cc591fd7e1c01aee8f1 (diff)
downloadzsh-81a331a3eaf81352b0f06a7b91f9ced73be04741.tar.gz
zsh-81a331a3eaf81352b0f06a7b91f9ced73be04741.zip
21779 plus unposted catch change: exception improvementss
-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