9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: [9fans] rc error messages
Date: Tue, 21 Oct 2008 13:04:32 -0400	[thread overview]
Message-ID: <a0d7e5c5b3eb0695a5105180735dca0b@quanstro.net> (raw)

steve mentioned that rc is not very forthcoming with information on
where runtime errors occur.

here's a little patch that makes rc a little bit more forthcoming.
but it's still pretty useless in the face of functions.

- erik

; diff -c exec.c /n/dump/2008/1021/sys/src/cmd/rc/exec.c
exec.c:887,916 - /n/dump/2008/1021/sys/src/cmd/rc/exec.c:887,898
  }

  void
- hisfault(char *buf, int n)
- {
- 	struct thread *t;
-
- 	for(t = runq; !t->cmdfile; t = t->ret){
- 		if(t->ret == 0)
- 			break;
- 	}
- 	if(t->cmdfile && !t->iflag)
- 		snprint(buf, n, "%s:%d ", t->cmdfile, t->lineno);
- 	else
- 		snprint(buf, n, "");
- }
-
- void
  Xerror(char *s)
  {
- 	char buf[1024];
-
- 	hisfault(buf, sizeof buf);
  	if(strcmp(argv0, "rc")==0 || strcmp(argv0, "/bin/rc")==0)
- 		pfmt(err, "rc: %s%s: %r\n", buf, s);
+ 		pfmt(err, "rc: %s: %r\n", s);
  	else
- 		pfmt(err, "rc (%s): %s%s: %r\n", argv0, buf, s);
+ 		pfmt(err, "rc (%s): %s: %r\n", argv0, s);
  	flush(err);
  	setstatus("error");
  	while(!runq->iflag) Xreturn();
exec.c:919,931 - /n/dump/2008/1021/sys/src/cmd/rc/exec.c:901,910
  void
  Xerror1(char *s)
  {
- 	char buf[1024];
-
- 	hisfault(buf, sizeof buf);
  	if(strcmp(argv0, "rc")==0 || strcmp(argv0, "/bin/rc")==0)
- 		pfmt(err, "rc: %s%s\n", buf, s);
+ 		pfmt(err, "rc: %s\n", s);
  	else
- 		pfmt(err, "rc (%s): %s%s\n", argv0, buf, s);
+ 		pfmt(err, "rc (%s): %s\n", argv0, s);
  	flush(err);
  	setstatus("error");
  	while(!runq->iflag) Xreturn();




             reply	other threads:[~2008-10-21 17:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21 17:04 erik quanstrom [this message]
2008-10-22 10:06 ` Steve Simon
2008-10-22 10:07 ` Steve Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0d7e5c5b3eb0695a5105180735dca0b@quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).