mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
foot{,client}: handle argc == 0
Our getopt_long() based argument parser would (correctly) break out of the while loop immediately. However, we would then proceed and decrement ‘argc’ by 1, resulting in it being -1. This was then passed to the terminal constructor, which passed it on to the client application fork+exec logic. That finally resulted in an exec(3) failure: err: slave.c:339: SHELL=/bin/zsh: failed to execute: No such file or directory err: fdm.c:215: no such FD: 7 info: main.c:604: goodbye
This commit is contained in:
parent
b83daaac46
commit
9f26b250bb
2 changed files with 10 additions and 6 deletions
8
client.c
8
client.c
|
|
@ -124,7 +124,7 @@ main(int argc, char *const *argv)
|
|||
static const int foot_exit_failure = -36;
|
||||
int ret = foot_exit_failure;
|
||||
|
||||
const char *const prog_name = argv[0];
|
||||
const char *const prog_name = argc > 0 ? argv[0] : "<nullptr>";
|
||||
|
||||
static const struct option longopts[] = {
|
||||
{"term", required_argument, NULL, 't'},
|
||||
|
|
@ -309,8 +309,10 @@ main(int argc, char *const *argv)
|
|||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc > 0) {
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
}
|
||||
|
||||
log_init(log_colorize, false, LOG_FACILITY_USER, log_level);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue