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

Re: PATCH: Re: Is PRINT_EXIT_VALUE supposed to work?



On Jul 3,  6:13pm, Peter Stephenson wrote:
} Subject: Re: PATCH: Re: Is PRINT_EXIT_VALUE supposed to work?
}
} I've been a long time getting around to looking at this, but does this
} really work?
} 
}   zsh -c 'setopt printexitvalue; fn() { false;}; fn'

This works for me now:

schaefer[652] Src/zsh -fc 'setopt printexitvalue; fn() { false;}; fn'
zsh: exit 1
schaefer[653] Src/zsh -fc 'fn() { false;}; fn'
schaefer[654] 

I can't see anything that might have changed since 15057 that would have
affected this, but there it is.

Meanwhile, I think I've spotted a bug in doshfunc().  Can someone explain
why the following (or something better that doesn't use `goto') is not
necessary?  (I won't commit it until I get second opinions from Sven and
PWS.)

Index: Src/exec.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/exec.c,v
retrieving revision 1.7
diff -c -r1.7 exec.c
--- exec.c	2001/06/28 08:40:25	1.7
+++ exec.c	2001/07/08 15:17:02
@@ -3359,9 +3359,7 @@
     if(++funcdepth > MAX_FUNCTION_DEPTH)
     {
         zerr("maximum nested function level reached", NULL, 0);
-	scriptname = oldscriptname;
-	popheap();
-	return;
+	goto undoshfunc;
     }
 #endif
     fstack.name = dupstring(name);
@@ -3382,14 +3380,14 @@
 		errflag = 1;
 	    else
 		lastval = 1;
-	    popheap();
-	    scriptname = oldscriptname;
-	    return;
+	    goto doneshfunc;
 	}
 	prog = shf->funcdef;
     }
     runshfunc(prog, wrappers, fstack.name);
+ doneshfunc:
     funcstack = fstack.prev;
+ undoshfunc:
 #ifdef MAX_FUNCTION_DEPTH
     --funcdepth;
 #endif


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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