From: Peter Stephenson <pws@csr.com>
To: zsh-workers@zsh.org (Zsh hackers list)
Subject: PATCH: return status from read
Date: Fri, 07 Jan 2011 10:00:49 +0000 [thread overview]
Message-ID: <9843.1294394449@csr.com> (raw)
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
reply other threads:[~2011-01-07 10:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9843.1294394449@csr.com \
--to=pws@csr.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).