zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: return status from read
@ 2011-01-07 10:00 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2011-01-07 10:00 UTC (permalink / raw)
  To: Zsh hackers list

Checking up on something reported on the Austin group list, I found that
the read builtin doesn't return a non-zero status when there's an error
assigning a parameter, even though the error flag is correctly set,
which is plain inconsistent.

You could argue that the builtin handler should turn a status 0 into a 1
if errflag is set on return from the builtin, but that's a bit murky.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.245
diff -p -u -r1.245 builtin.c
--- Src/builtin.c	15 Oct 2010 18:56:17 -0000	1.245
+++ Src/builtin.c	7 Jan 2011 09:55:29 -0000
@@ -5710,7 +5710,7 @@ bin_read(char *name, char **args, Option
 	}
 	return 1;
     }
-    return 0;
+    return errflag;
 }
 
 /**/
Index: Test/B04read.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/B04read.ztst,v
retrieving revision 1.4
diff -p -u -r1.4 B04read.ztst
--- Test/B04read.ztst	24 Jul 2009 18:35:53 -0000	1.4
+++ Test/B04read.ztst	7 Jan 2011 09:55:29 -0000
@@ -88,3 +88,8 @@
  print ${#line}
 0:read with trailing metafied characters
 >24  
+
+ (typeset -r foo
+  read foo) <<<bar
+1:return status on failing to set parameter
+?(eval):2: read-only variable: foo

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


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-07 10:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-07 10:00 PATCH: return status from read 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).