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

Re: Line number monstrosity



I wrote:
> % autoload flubba
> % flubba
> flubba:104: flubba: function definition file not found
> 
> The only problem is the `flubba:104:' at the start of the error message.
> It's not in the function yet, so shouldn't print that.

This seems to be enough.  It even now works if the function tried to
autoload itself from within another function; maybe locallevel and the
badly-named variable scriptname should be tied more closely together so
that the name of the currently active thingummybob changes at the same time
as the locallevel, which is more logical.

It would be quite nice to be able to select whether the `flubba:104' prefix
is printed inside a function (I have pushd as a function and it's a bit
annoying that you get different error messages from the builtin).  An
option to switch that off isn't hard.  An option to ignore a level of
functions and report that the error occurred in the containing function
would be rather harder, since we don't have a stack of thingummybob
names/linenos as we'd need.  Maybe the first possibility would be enough.
Maybe configurable error messages are better.

Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.10
diff -u -r1.10 exec.c
--- Src/exec.c	2000/06/20 16:38:10	1.10
+++ Src/exec.c	2000/07/11 16:30:17
@@ -3201,7 +3201,10 @@
 	ksh = fksh;
 
     if (prog == &dummy_eprog) {
+	/* We're not actually in the function; decrement locallevel */
+	locallevel--;
 	zerr("%s: function definition file not found", shf->nam, 0);
+	locallevel++;
 	popheap();
 	return NULL;
     }

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070



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