aboutsummaryrefslogtreecommitdiff
path: root/smash/main.c
diff options
context:
space:
mode:
authorNathan P. Reiner <nathan@nathanreiner.xyz>2022-12-16 09:33:11 +0100
committerNathan P. Reiner <nathan@nathanreiner.xyz>2022-12-16 09:33:11 +0100
commit10c4a9af585869da2d26c136c49cc79f2ca45e50 (patch)
tree9ac955df56f1bf3e245312f5e370bd287f32d0bf /smash/main.c
parentd29b2c8af98f34745eca362fb1d65002170e7156 (diff)
implement wstdf
Diffstat (limited to 'smash/main.c')
-rw-r--r--smash/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/smash/main.c b/smash/main.c
index 0b3dc20..2422363 100644
--- a/smash/main.c
+++ b/smash/main.c
@@ -15,12 +15,16 @@ int main(int argc, char *argv[], char *envp[])
{
char buf[BUFSIZ] = {0};
char prompt[] = "$ ";
+ u64 line_length;
while (1) {
write(STDOUT_FD, prompt, cstr_length(prompt));
read(STDIN_FD, buf, 1024);
- buf[cstr_length(buf) - 1] = 0;
- exec(buf);
+ line_length = cstr_length(buf);
+ if (line_length > 1) {
+ buf[line_length - 1] = 0;
+ exec(buf);
+ }
clear_buf(buf);
}
}