aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Noll <nnoll523@gmail.com>2021-10-26 14:11:25 -0700
committerNicholas Noll <nnoll523@gmail.com>2021-10-26 14:11:25 -0700
commite34a4791b72e426b02f33496fe03be1ad81819a6 (patch)
tree85db47712e9218f172d47b394e8e4099232a159b
parent2416a8654e3c1a4b74fcc0379dac5294670a1f46 (diff)
fix(rc): prompt during command entry
-rw-r--r--sys/cmd/rc/exec.c2
-rw-r--r--sys/cmd/rc/prompt.c11
-rw-r--r--sys/cmd/rc/rc.h1
3 files changed, 10 insertions, 4 deletions
diff --git a/sys/cmd/rc/exec.c b/sys/cmd/rc/exec.c
index 5f3c6d6..1b311ec 100644
--- a/sys/cmd/rc/exec.c
+++ b/sys/cmd/rc/exec.c
@@ -914,6 +914,8 @@ Xreadcmd(void)
flush(shell.err);
root = runner;
+ shell.prompt = "> ";
+
if(yyparse()){
// resource cleanup?
if(runner->flag.eof)
diff --git a/sys/cmd/rc/prompt.c b/sys/cmd/rc/prompt.c
index e3ff7d9..d6846e6 100644
--- a/sys/cmd/rc/prompt.c
+++ b/sys/cmd/rc/prompt.c
@@ -1,16 +1,19 @@
#include "rc.h"
+
int
prompt(ushort *flag)
{
- int f = *flag;
+ int fd, f = *flag;
if(f){
- if(!readline("> ")){
+ if(!readline(shell.prompt)){
runner->flag.eof = 1;
return 0;
}
- print(shell.err,"\n\r");
- flush(shell.err);
+ fd = mapfd(0);
+ write(fd, "\n\r", 2);
+ shell.prompt = "> "; // NOTE: can't use tab here: we have a hacky prompt length computation
+
runner->line++;
*flag = 0;
}
diff --git a/sys/cmd/rc/rc.h b/sys/cmd/rc/rc.h
index e35c3e4..5a9aac5 100644
--- a/sys/cmd/rc/rc.h
+++ b/sys/cmd/rc/rc.h
@@ -152,6 +152,7 @@ struct Shell
Io *err;
int status;
int interactive;
+ char *prompt;
Thread *jobs;
};