summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rc/exec.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2021-06-22 23:40:11 +0000
committerOri Bernstein <ori@eigenstate.org>2021-06-22 23:40:11 +0000
commit577033228209f28350dc3f75ef9d4ce88dfdf190 (patch)
tree7540037c6ffd83810da4209abbdd6879a484e075 /sys/src/cmd/rc/exec.c
parentce73821f3575921e24f839b21c7be60520a9dc42 (diff)
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.
Diffstat (limited to 'sys/src/cmd/rc/exec.c')
-rw-r--r--sys/src/cmd/rc/exec.c5
1 files changed, 3 insertions, 2 deletions
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())