diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-12-25 16:27:57 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-12-28 01:01:15 -0500 |
commit | e4a192ec9c272b7be3ba54bd8ea5154d5af18dca (patch) | |
tree | bc3ee275680653e1fb6d63e1483884a0ba0ed48b /parse.c | |
parent | 36cb1762dd647a6c9cbb0ab36993c83798c854f1 (diff) | |
download | bfs-e4a192ec9c272b7be3ba54bd8ea5154d5af18dca.tar.xz |
parse: Handle argc == 0
Linux allows you to exec() with no argument list at all. Default to
"bfs" in that case.
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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()"); |