zsh-workers
 help / color / mirror / code / Atom feed
* Line number monstrosity
@ 2000-07-11 11:53 Peter Stephenson
  2000-07-11 13:40 ` Clint Adams
  2000-07-11 16:37 ` Peter Stephenson
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Stephenson @ 2000-07-11 11:53 UTC (permalink / raw)
  To: Zsh hackers list

% 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.  I haven't looked,
but the problem must be that autoload makes it think it is in the function,
since that's often useful contextwise.  It isn't here, since you get the
wrong line number (that's the interactive $LINENO at this point).

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
  2000-07-11 11:53 Line number monstrosity Peter Stephenson
@ 2000-07-11 13:40 ` Clint Adams
  2000-07-11 13:54   ` Sven Wischnowsky
  2000-07-11 16:37 ` Peter Stephenson
  1 sibling, 1 reply; 8+ messages in thread
From: Clint Adams @ 2000-07-11 13:40 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list

> 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.  I haven't looked,
> but the problem must be that autoload makes it think it is in the function,
> since that's often useful contextwise.  It isn't here, since you get the
> wrong line number (that's the interactive $LINENO at this point).

In a vaguely similar vein, the 14 in
cat:14: no such file or directory: nonexistent
isn't particularly useful.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
@ 2000-07-11 13:54   ` Sven Wischnowsky
  2000-07-11 14:57     ` Clint Adams
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-07-11 13:54 UTC (permalink / raw)
  To: zsh-workers


Clint Adams wrote:

> > 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.  I haven't looked,
> > but the problem must be that autoload makes it think it is in the function,
> > since that's often useful contextwise.  It isn't here, since you get the
> > wrong line number (that's the interactive $LINENO at this point).
> 
> In a vaguely similar vein, the 14 in
> cat:14: no such file or directory: nonexistent
> isn't particularly useful.

Hm. But then we need user-configurable error-message-strings (some
prompt-like thingy wit %-escapes). Or at least a line_numbers_not_useful
option.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
  2000-07-11 13:54   ` Sven Wischnowsky
@ 2000-07-11 14:57     ` Clint Adams
  2000-07-11 16:22       ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Clint Adams @ 2000-07-11 14:57 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-workers

> Hm. But then we need user-configurable error-message-strings (some
> prompt-like thingy wit %-escapes). Or at least a line_numbers_not_useful
> option.

Yup.  I suppose it's purely esthetic.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
  2000-07-11 14:57     ` Clint Adams
@ 2000-07-11 16:22       ` Bart Schaefer
  2000-07-11 16:35         ` Bart Schaefer
  2000-07-11 16:38         ` Clint Adams
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-07-11 16:22 UTC (permalink / raw)
  To: Zsh hackers list

On Jul 11, 12:53pm, Peter Stephenson 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.

It should be possible to fix that by temporarily decrementing locallevel
in loadautofn().  The question is whether to decrement it just for that
particular error message, or for the entire duration of that C function
(including errors such as "function not defined by file").

On a related note, I'm a little puzzled by this behavior:

zagzig% cat < nonexistent         
zagzig% echo < nonexistent
zsh: no such file or directory: nonexistent
zagzig% cat < nonexistent 
zagzig% 

Why is there no error message for the bad redirection when the command is
not a builtin?

On Jul 11,  9:40am, Clint Adams wrote:
}
} In a vaguely similar vein, the 14 in
} cat:14: no such file or directory: nonexistent
} isn't particularly useful.

Why not?  You don't get line numbers for commands issued from the PS1
prompt, so you must be referring to something in a function or script;
and it's possible to have more than one "cat" in the same script, and to
need to know which of those failed.

-- 
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   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
  2000-07-11 16:22       ` Bart Schaefer
@ 2000-07-11 16:35         ` Bart Schaefer
  2000-07-11 16:38         ` Clint Adams
  1 sibling, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2000-07-11 16:35 UTC (permalink / raw)
  To: Zsh hackers list

On Jul 11,  4:22pm, Bart Schaefer wrote:
}
} zagzig% cat < nonexistent 
} zagzig% 
} 
} Why is there no error message for the bad redirection when the command is
} not a builtin?

Because I'm running inside a debugger and the external command is crashing
on the breakpoint trap.  In other words, never mind.

-- 
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   


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
  2000-07-11 11:53 Line number monstrosity Peter Stephenson
  2000-07-11 13:40 ` Clint Adams
@ 2000-07-11 16:37 ` Peter Stephenson
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2000-07-11 16:37 UTC (permalink / raw)
  To: Zsh hackers list

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@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Line number monstrosity
  2000-07-11 16:22       ` Bart Schaefer
  2000-07-11 16:35         ` Bart Schaefer
@ 2000-07-11 16:38         ` Clint Adams
  1 sibling, 0 replies; 8+ messages in thread
From: Clint Adams @ 2000-07-11 16:38 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

> zagzig% cat < nonexistent         

I can't reproduce this, FWIW.

> Why not?  You don't get line numbers for commands issued from the PS1
> prompt, so you must be referring to something in a function or script;
> and it's possible to have more than one "cat" in the same script, and to
> need to know which of those failed.

No, I wasn't clear.  I'm using the cat function.  The fact that it can't
find the file at line 14 is not useful unless I'm debugging the cat function.
On the other hand, it's a useful indicator that you're using a function instead
of /bin/cat.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-07-11 16:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-11 11:53 Line number monstrosity Peter Stephenson
2000-07-11 13:40 ` Clint Adams
2000-07-11 13:54   ` Sven Wischnowsky
2000-07-11 14:57     ` Clint Adams
2000-07-11 16:22       ` Bart Schaefer
2000-07-11 16:35         ` Bart Schaefer
2000-07-11 16:38         ` Clint Adams
2000-07-11 16:37 ` Peter Stephenson

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).