From d5027bff5005ba1b4b92f64bebeea673fd538523 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 13 Oct 2021 21:52:17 +0200 Subject: init/shell: show the current "fork depth" in the prompt --- src/init/shell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/init/shell.c b/src/init/shell.c index 6e1dee2..130ae79 100644 --- a/src/init/shell.c +++ b/src/init/shell.c @@ -2,8 +2,6 @@ #include #include -#define PROMPT "$ " - static char *split(char *base) { while (*base) { if (*base == ' ' || *base == '\t') { @@ -60,10 +58,11 @@ static void cmd_cat(const char *args) { void shell_loop(void) { static char cmd[256]; + int level = 0; char *args; for (;;) { - printf(PROMPT); + printf("%x$ ", level); readline(cmd, 256); args = split(cmd); if (!strcmp(cmd, "echo")) { @@ -75,6 +74,7 @@ void shell_loop(void) { } else if (!strcmp(cmd, "fork")) { if (_syscall_fork()) _syscall_await(); + else level++; } else { printf("unknown command :(\n"); } -- cgit v1.2.3