summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-12 13:46:24 -0400
committerIan Moffett <ian@osmora.org>2025-10-12 13:46:24 -0400
commitddd6a604857e3d2501fdc7cdef0b722d5520e4dd (patch)
tree7fd255613e925e846da145a5217dcd99c0e00747
parent51369c989cc490d96f6db7c3c3741f9793da1ae4 (diff)
cmd: hush: Add initial program spawning
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--src/cmd/hush/hush.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/cmd/hush/hush.c b/src/cmd/hush/hush.c
index bd6ca6f..3d623df 100644
--- a/src/cmd/hush/hush.c
+++ b/src/cmd/hush/hush.c
@@ -95,19 +95,22 @@ read_input(char *buf, size_t maxlen)
int
main(void)
{
+ char *argv[2];
char buf[128];
- ssize_t retval;
+ char binpath[256];
+ int error;
+
+ argv[0] = binpath;
+ argv[1] = NULL;
for (;;) {
write(STDOUT_FILENO, PROMPT, sizeof(PROMPT) - 1);
read_input(buf, sizeof(buf));
write(STDOUT_FILENO, "\n", 1);
- /* XXX: For initial demonstration */
- if (strcmp(buf, "hello") == 0) {
- puts("meow!!");
- } else {
- puts("mrrp?");
+ snprintf(binpath, sizeof(binpath), "/usr/bin/%s", buf);
+ if ((error = spawn(argv[0], argv)) < 0) {
+ printf("unknown command \"%s\"\n", buf);
}
buf[0] = '\0';