From 01cf390a1ffeffe83b67336de2889118c5f506d5 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 1 Apr 2020 15:31:37 -0400 Subject: better support for -c "command" --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 61b55f3..acddea7 100644 --- a/main.c +++ b/main.c @@ -72,9 +72,12 @@ int sh_main(int argc, char *argv[]) if (mode == COMMAND) { /* shift argv */ - execvp(argv[optind], argv + optind); - fprintf(stderr, "sh: %s: %s\n", argv[optind], strerror(errno)); - return 1; + /* TODO: join all remaining args together before parsing */ + struct command *cmd = sh_parse(argv[optind]); + return sh_execute(cmd); + //execvp(argv[optind], argv + optind); + //fprintf(stderr, "sh: %s: %s\n", argv[optind], strerror(errno)); + //return 1; } if (argv[optind] == NULL && isatty(STDIN_FILENO) && isatty(STDERR_FILENO)) { -- cgit v1.2.1