summaryrefslogtreecommitdiff
path: root/src/init/shell.c
diff options
context:
space:
mode:
authordzwdz2021-10-10 15:38:12 +0000
committerdzwdz2021-10-10 15:38:12 +0000
commite95ab7393a267f15fb7be915efb2538382bbf838 (patch)
tree3b16842f81dca628832a55a4ec4c41b561e68bf4 /src/init/shell.c
parentac2252793a6e2a380bd215f62291ca2fe4f973b2 (diff)
init/shell: basic argument splitting
Diffstat (limited to 'src/init/shell.c')
-rw-r--r--src/init/shell.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/init/shell.c b/src/init/shell.c
index d61f46f..12382e0 100644
--- a/src/init/shell.c
+++ b/src/init/shell.c
@@ -6,6 +6,17 @@
static int tty_fd = 0; // TODO put in stdlib
+static char *split(char *base) {
+ while (*base) {
+ if (*base == ' ' || *base == '\t') {
+ *base++ = '\0';
+ return base;
+ }
+ base++;
+ }
+ return NULL;
+}
+
static int readline(char *buf, size_t max) {
char c;
size_t pos = 0;
@@ -36,9 +47,12 @@ static int readline(char *buf, size_t max) {
void shell_loop(void) {
static char cmd[256];
+ char *args;
+
for (;;) {
printf(PROMPT);
readline(cmd, 256);
- printf(" %s\n", cmd);
+ args = split(cmd);
+ printf(" %s | %s\n", cmd, args);
}
}