zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: make zsh print errors like a well-behaved compiler
@ 1999-11-25 17:20 Clint Adams
  1999-11-25 17:58 ` Bart Schaefer
  1999-11-25 18:21 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Clint Adams @ 1999-11-25 17:20 UTC (permalink / raw)
  To: zsh-workers

This will change the error given when running a script
from something like

/tmp/brokenscript: command not found: badcommand [5]
/tmp/brokenscript:5: command not found: badcommand

This makes it parsable for emacs's compile-goto-error
and all sorts of other fun software that can now
be led to believe that zsh is a compiler.

It also makes 5 look more like a line number instead
of a possible error code.

--- Src/utils.c	1999/11/05 15:49:30	1.1.1.42
+++ Src/utils.c	1999/11/25 17:05:29
@@ -76,7 +76,7 @@
      */
     nicezputs((isset(SHINSTDIN) && !locallevel) ? "zsh" :
 	      scriptname ? scriptname : argzero, stderr);
-    fputs(": ", stderr);
+    fputc((unsigned char)':', stderr);
     zerrmsg(fmt, str, num);
 }
 
@@ -89,11 +89,11 @@
     trashzle();
     if (unset(SHINSTDIN) || locallevel) {
 	nicezputs(scriptname ? scriptname : argzero, stderr);
-	fputs(": ", stderr);
+	fputc((unsigned char)':', stderr);
     }
     if (cmd) {
 	nicezputs(cmd, stderr);
-	fputs(": ", stderr);
+	fputc((unsigned char)':', stderr);
     }
     zerrmsg(fmt, str, num);
 }
@@ -102,6 +102,11 @@
 void
 zerrmsg(const char *fmt, const char *str, int num)
 {
+    if ((unset(SHINSTDIN) || locallevel) && lineno)
+	fprintf(stderr, "%ld: ", (long)lineno);
+    else
+	fputc((unsigned char)' ', stderr);
+
     while (*fmt)
 	if (*fmt == '%') {
 	    fmt++;
@@ -149,10 +154,7 @@
 	    putc(*fmt == Meta ? *++fmt ^ 32 : *fmt, stderr);
 	    fmt++;
 	}
-    if ((unset(SHINSTDIN) || locallevel) && lineno)
-	fprintf(stderr, " [%ld]\n", (long)lineno);
-    else
-	putc('\n', stderr);
+    putc('\n', stderr);
     fflush(stderr);
 }


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

* Re: PATCH: make zsh print errors like a well-behaved compiler
  1999-11-25 17:20 PATCH: make zsh print errors like a well-behaved compiler Clint Adams
@ 1999-11-25 17:58 ` Bart Schaefer
  1999-11-25 18:21 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-11-25 17:58 UTC (permalink / raw)
  To: zsh-workers

On Nov 25, 12:20pm, Clint Adams wrote:
} Subject: PATCH: make zsh print errors like a well-behaved compiler
}
} This will change the error given when running a script

I've actually been wondering whether this sort of thing should be
configurable (PS5, anyone?).  In some circumstances one might not
want line numbers at all; in fact, in some cases one might rather
see

	badcommand: command not found

instead of

	scriptname: command not found: badcommand


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


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

* Re: PATCH: make zsh print errors like a well-behaved compiler
  1999-11-25 17:20 PATCH: make zsh print errors like a well-behaved compiler Clint Adams
  1999-11-25 17:58 ` Bart Schaefer
@ 1999-11-25 18:21 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-11-25 18:21 UTC (permalink / raw)
  To: zsh-workers

On Nov 25, 12:20pm, Clint Adams wrote:
} Subject: PATCH: make zsh print errors like a well-behaved compiler
}
} This makes it parsable for emacs's compile-goto-error

Not that I particularly object to the change to zsh, but:

(setq compilation-error-regexp-alist
      (append compilation-error-regexp-alist
	      '(("^\\([^:]*\\): .*\\[\\([0-9]+\\)\\]" 1 2))))

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


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

end of thread, other threads:[~1999-11-25 18:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-25 17:20 PATCH: make zsh print errors like a well-behaved compiler Clint Adams
1999-11-25 17:58 ` Bart Schaefer
1999-11-25 18:21 ` Bart Schaefer

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