zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: tests for `always' syntax
@ 2004-06-21 10:40 Peter Stephenson
  2004-06-21 16:12 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2004-06-21 10:40 UTC (permalink / raw)
  To: Zsh hackers list

Here are tests for the `always' syntax in the second form.  Is that
now relatively uncontroversial?

I tweaked the description of status handling in grammar.yo which was
split between two places and wedge up against the block with error
handling, from which I should have distinguished it more clearly.  It
now reads:

  Regardless of tt(TRY_BLOCK_ERROR), after the end of tt(always-list) the
  normal shell status tt($?) is the value returned from tt(always-list).
  This will be non-zero if there was an error, even if tt(TRY_BLOCK_ERROR)
  was set to zero.

Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.8
diff -u -r1.8 A01grammar.ztst
--- Test/A01grammar.ztst	1 Apr 2003 14:04:10 -0000	1.8
+++ Test/A01grammar.ztst	21 Jun 2004 10:35:07 -0000
@@ -263,6 +263,85 @@
 0:basic [[ ... ]] test
 
 #
+# Current shell execution with try/always form.
+# We put those with errors in subshells so that any unhandled error doesn't
+# propagate.
+#
+
+  {
+     print The try block.
+  } always {
+     print The always block.
+  }
+  print After the always block.
+0:Basic `always' syntax
+>The try block.
+>The always block.
+>After the always block.
+
+  ({
+    print Position one.
+    print ${*this is an error*}
+    print Position two.
+  } always {
+    if (( TRY_BLOCK_ERROR )); then
+      print An error occurred.
+    else
+      print No error occurred.
+    fi
+  }
+  print Position three)
+1:Always block with error not reset
+>Position one.
+>An error occurred.
+?(eval):3: bad substitution
+
+  ({
+    print Stelle eins.
+    print ${*voici une erreur}
+    print Posizione due.
+  } always {
+    if (( TRY_BLOCK_ERROR )); then
+      print Erratum factum est. Retro ponetur.
+      (( TRY_BLOCK_ERROR = 0 ))
+    else
+      print unray touay foay anguageslay
+    fi
+  }
+  print Status after always block is $?.)
+0:Always block with error reset
+>Stelle eins.
+>Erratum factum est. Retro ponetur.
+>Status after always block is 1.
+?(eval):3: bad substitution
+
+# Outputting of structures from the wordcode is distinctly non-trivial,
+# we probably ought to have more like the following...
+  fn1() { { echo foo; } }
+  fn2() { { echo foo; } always { echo bar; } }
+  fn3() { ( echo foo; ) }
+  functions fn1 fn2 fn3
+0:Output of syntactic structures with and without always blocks
+>fn1 () {
+>	{
+>		echo foo
+>	}
+>}
+>fn2 () {
+>	{
+>		echo foo
+>	} always {
+>		echo bar
+>	}
+>}
+>fn3 () {
+>	(
+>		echo foo
+>	)
+>}
+
+
+#
 # Tests for `Alternate Forms For Complex Commands'
 #
 
-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, 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.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: PATCH: tests for `always' syntax
  2004-06-21 10:40 PATCH: tests for `always' syntax Peter Stephenson
@ 2004-06-21 16:12 ` Bart Schaefer
  2004-06-22 13:11   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2004-06-21 16:12 UTC (permalink / raw)
  To: Zsh hackers list

On Mon, 21 Jun 2004, Peter Stephenson wrote:

> Here are tests for the `always' syntax in the second form.  Is that
> now relatively uncontroversial?

Yep, I think it's fine.


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

* Re: PATCH: tests for `always' syntax
  2004-06-21 16:12 ` Bart Schaefer
@ 2004-06-22 13:11   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2004-06-22 13:11 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer wrote:
> On Mon, 21 Jun 2004, Peter Stephenson wrote:
> > Here are tests for the `always' syntax in the second form.  Is that
> > now relatively uncontroversial?
> 
> Yep, I think it's fine.

I've now committed the changes.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, 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.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

end of thread, other threads:[~2004-06-22 13:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-21 10:40 PATCH: tests for `always' syntax Peter Stephenson
2004-06-21 16:12 ` Bart Schaefer
2004-06-22 13:11   ` 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).