summaryrefslogtreecommitdiff
path: root/src/user/init
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-13 22:06:40 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-13 22:06:40 -0400
commit44d29a33df81ac07163d5146a9e43a0c4fb80af0 (patch)
tree94d4fb506a80d73cb53dc9ea66dfc952d7a9432a /src/user/init
parent143156f63e2448733f1a35a74e629fe0ae9bb567 (diff)
downloadportland-os-44d29a33df81ac07163d5146a9e43a0c4fb80af0.tar.gz
new shell
Diffstat (limited to 'src/user/init')
-rw-r--r--src/user/init/init.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/src/user/init/init.c b/src/user/init/init.c
index e878603..fb231e0 100644
--- a/src/user/init/init.c
+++ b/src/user/init/init.c
@@ -2,19 +2,6 @@
#include <knob/file.h>
#include <knob/task.h>
-void start(const char *cmd) {
- tell_user_sz("[init] Starting ");
- tell_user_sz(cmd);
- tell_user_sz(": ");
- tell_user_sz(
- run_command(cmd)
- ? "Succeded.\n"
- : "Failed.\n"
- );
- tell_user_sz("[init] Yielding.\n");
- yield_task();
-}
-
#define STARTUP_FILE_PATH "sys/startup.rc"
void main() {
@@ -26,22 +13,17 @@ void main() {
tell_user_sz("[init] Reading from " STARTUP_FILE_PATH ".\n");
- char buf[1024];
- char *bufp = buf;
- while (read_from_file(f, 1, bufp)) {
- if (*bufp == '\n') {
- if (bufp == buf)
- continue;
- *bufp = '\0';
- start(buf);
- bufp = buf;
+ char cmdbuf[128];
+ while (read_line_from_file(f, cmdbuf, 127)) {
+ tell_user_sz("[init] Starting ");
+ tell_user_sz(cmdbuf);
+ tell_user_sz(": ");
+ if (run_command(cmdbuf)) {
+ tell_user_sz("Succeded.\n");
+ yield_task();
}
else
- ++bufp;
- }
- if (bufp != buf) {
- *bufp = '\0';
- start(buf);
+ tell_user_sz("Failed.\n");
}
close_file(f);