diff options
| author | Nathan P. Reiner <nathan@nathanreiner.xyz> | 2022-12-16 09:33:11 +0100 |
|---|---|---|
| committer | Nathan P. Reiner <nathan@nathanreiner.xyz> | 2022-12-16 09:33:11 +0100 |
| commit | 10c4a9af585869da2d26c136c49cc79f2ca45e50 (patch) | |
| tree | 9ac955df56f1bf3e245312f5e370bd287f32d0bf /smash/main.c | |
| parent | d29b2c8af98f34745eca362fb1d65002170e7156 (diff) | |
implement wstdf
Diffstat (limited to 'smash/main.c')
| -rw-r--r-- | smash/main.c | 8 |
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); } } |