Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] typeset: set $? on incidental error

On Fri, 15 Jan 2016 09:54:37 -0500
Eric Cook <llua@xxxxxxx> wrote:
> But typeset should exit > 0 when it does fail to assign a parameter.

This looks about the minimal fix for this.

This is already a hard error, so will cause other stuff later in the
command to fail, however the error wasn't propagated properly within the
command handler.


diff --git a/Src/builtin.c b/Src/builtin.c
index e1a7990..dd20f9e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2213,6 +2213,8 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
 				 mkarray(NULL), 0)))
 		return NULL;
+	if (errflag)
+	    return NULL;
 	pm->node.flags |= (on & PM_READONLY);
 	if (OPT_ISSET(ops,'p'))
 	    paramtab->printnode(&pm->node, PRINT_TYPESET);
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 681fe73..d6d2421 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -706,3 +706,8 @@
 >typeset -a array=( '' two '' four )
 >typeset -a array=( one '' three )
 >no really nothing here
+  readonly isreadonly=yes
+  typeset isreadonly=still
+1:typeset returns status 1 if setting readonly variable
+?(eval):2: read-only variable: isreadonly

Messages sorted by: Reverse Date, Date, Thread, Author