aboutsummaryrefslogtreecommitdiff
path: root/smash
diff options
context:
space:
mode:
authorNathan P. Reiner <nathan@nathanreiner.xyz>2022-12-16 10:50:23 +0100
committerNathan P. Reiner <nathan@nathanreiner.xyz>2022-12-16 10:50:23 +0100
commit94252fadadc5f49bf15ce3533372155f360b58ff (patch)
tree85f079de1d21ed990759382686ccb2c823c97a3e /smash
parentd5ed22276d65a0ef3d9bbe586ff4a2bbfd779714 (diff)
exit on EOF
Diffstat (limited to 'smash')
-rw-r--r--smash/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/smash/main.c b/smash/main.c
index 2422363..ca7d4fa 100644
--- a/smash/main.c
+++ b/smash/main.c
@@ -21,10 +21,15 @@ int main(int argc, char *argv[], char *envp[])
write(STDOUT_FD, prompt, cstr_length(prompt));
read(STDIN_FD, buf, 1024);
line_length = cstr_length(buf);
- if (line_length > 1) {
+
+ if (line_length == 0)
+ return 0;
+
+ if (line_length == 1) {
buf[line_length - 1] = 0;
exec(buf);
}
+
clear_buf(buf);
}
}