diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-02 14:20:38 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-03-02 14:20:38 +1300 |
commit | d0b392c0a4c4ef72a972a32cee2a4e4f155faf5f (patch) | |
tree | 04ca5d9349dc0d463d0edc89a5219c3213c035d1 /loop.c | |
download | spsh-d0b392c0a4c4ef72a972a32cee2a4e4f155faf5f.tar.gz spsh-d0b392c0a4c4ef72a972a32cee2a4e4f155faf5f.zip |
First commit of sps(1)
Diffstat (limited to 'loop.c')
-rw-r--r-- | loop.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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; +} + |