From 577033228209f28350dc3f75ef9d4ce88dfdf190 Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Tue, 22 Jun 2021 23:40:11 +0000 Subject: rc: correct line numbers When loading a file using ".", we could end up with our line numbers thrown off due to the mutation of lexline. Putting lexline into the runq beside the file that we're reading from causes it to get pushed and popped correctly, so that we no longer lose track of our location. --- sys/src/cmd/rc/exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/src/cmd/rc/exec.c') diff --git a/sys/src/cmd/rc/exec.c b/sys/src/cmd/rc/exec.c index 04b3a4120..bbb13a17c 100644 --- a/sys/src/cmd/rc/exec.c +++ b/sys/src/cmd/rc/exec.c @@ -23,7 +23,7 @@ start(code *c, int pc, var *local) p->cmdfd = 0; p->eof = 0; p->iflag = 0; - p->lineno = 1; + p->lineno = runq ? runq->lineno : 1; p->ret = runq; runq = p; } @@ -203,12 +203,12 @@ main(int argc, char *argv[]) bootstrap[i].i = 0; start(bootstrap, 1, (var *)0); runq->cmdfile = strdup("rc"); + runq->lexline = 0; /* prime bootstrap argv */ pushlist(); argv0 = estrdup(argv[0]); for(i = argc-1;i!=0;--i) pushword(argv[i]); - lexline = 0; for(;;){ if(flag['r']) @@ -922,6 +922,7 @@ Xrdcmds(void) { struct thread *p = runq; word *prompt; + flush(err); nerror = 0; if(flag['s'] && !truestatus()) -- cgit v1.2.3