diff options
author | dzwdz | 2021-10-13 21:52:17 +0200 |
---|---|---|
committer | dzwdz | 2021-10-13 21:52:17 +0200 |
commit | d5027bff5005ba1b4b92f64bebeea673fd538523 (patch) | |
tree | 7696ba894240bb967189e1231f052baa61a431e9 /src/init/shell.c | |
parent | 455d9e675dd243e9147bce23c226cb0c60ec0ec4 (diff) |
init/shell: show the current "fork depth" in the prompt
Diffstat (limited to 'src/init/shell.c')
-rw-r--r-- | src/init/shell.c | 6 |
1 files changed, 3 insertions, 3 deletions
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 <init/stdlib.h> #include <shared/syscalls.h> -#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"); } |