From a89f0559c210def9a40bfeb9da6b38128a49cb55 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 7 Jan 2011 10:05:35 +0000 Subject: [PATCH] 28590: make read return status non-zero on error --- ChangeLog | 5 ++++- Src/builtin.c | 7 ++++++- Test/B04read.ztst | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fddf16222..68aad4aba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-01-07 Peter Stephenson + * 28590 (added a comment): Src/builtin.c, Test/B04read.ztst: + read builtin should return non-zero status on error. + * Mikael: 28585: Completion/Unix/Command/_mkdir: don't set ret=0 when _wanted fails to find any matches. @@ -14066,5 +14069,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5174 $ +* $Revision: 1.5175 $ ***************************************************** diff --git a/Src/builtin.c b/Src/builtin.c index 411b834e7..a85a49a20 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -5710,7 +5710,12 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func)) } return 1; } - return 0; + /* + * The following is to ensure a failure to set the parameter + * causes a non-zero status return. There are arguments for + * turning a non-zero status into errflag more widely. + */ + return errflag; } /**/ diff --git a/Test/B04read.ztst b/Test/B04read.ztst index 2c87aa67a..ad427dc0d 100644 --- a/Test/B04read.ztst +++ b/Test/B04read.ztst @@ -88,3 +88,8 @@ print ${#line} 0:read with trailing metafied characters >24 + + (typeset -r foo + read foo) <<