From e4a192ec9c272b7be3ba54bd8ea5154d5af18dca Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 25 Dec 2018 16:27:57 -0500 Subject: parse: Handle argc == 0 Linux allows you to exec() with no argument list at all. Default to "bfs" in that case. --- parse.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'parse.c') diff --git a/parse.c b/parse.c index 524a80d..70987b6 100644 --- a/parse.c +++ b/parse.c @@ -3108,6 +3108,12 @@ struct cmdline *parse_cmdline(int argc, char *argv[]) { cmdline->open_files = NULL; cmdline->nopen_files = 0; + static char* default_argv[] = {"bfs", NULL}; + if (argc < 1) { + argc = 1; + argv = default_argv; + } + cmdline->argv = malloc((argc + 1)*sizeof(*cmdline->argv)); if (!cmdline->argv) { perror("malloc()"); -- cgit v1.2.3