aboutsummaryrefslogtreecommitdiff
path: root/loop.c
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-03-02 14:20:38 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-03-02 14:20:38 +1300
commitd0b392c0a4c4ef72a972a32cee2a4e4f155faf5f (patch)
tree04ca5d9349dc0d463d0edc89a5219c3213c035d1 /loop.c
downloadspsh-d0b392c0a4c4ef72a972a32cee2a4e4f155faf5f.tar.gz
spsh-d0b392c0a4c4ef72a972a32cee2a4e4f155faf5f.zip
First commit of sps(1)
Diffstat (limited to 'loop.c')
-rw-r--r--loop.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/loop.c b/loop.c
new file mode 100644
index 0000000..107b4b2
--- /dev/null
+++ b/loop.c
@@ -0,0 +1,27 @@
+#include "sps.h"
+
+/* Loop through reading commands until we see an EOF (^D) */
+void loop() {
+ char *line;
+
+ /* Loop until we break */
+ while (1) {
+
+ /* Read a line from the user */
+ line = readline(PROMPT);
+
+ /* If the line is valid, try to run it as a command */
+ if (line != NULL) {
+ cmd(line);
+ }
+
+ /* If the line is EOF (^D), break out of the loop */
+ else {
+ fputs("\n", stdout);
+ break;
+ }
+ }
+
+ return;
+}
+