1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-12 21:46:01 +01:00

find-roots: Fix --help and invalid cli flags

- Make `--help` and `-h` valid cli flags that show the (short) help
- Prevent the program from segfaulting when an invalid option is passed
This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:37 +02:00
parent beac0b49e4
commit aa97c4f9f2

View file

@ -30,17 +30,20 @@ TracerConfig parseCmdLine(int argc, char** argv)
{ "socket_path", required_argument, 0, 'l' },
{ "store_dir", required_argument, 0, 's' },
{ "state_dir", required_argument, 0, 'd' },
{ "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 },
};
int option_index = 0;
int opt_char;
while((opt_char = getopt_long(argc, argv, "vd:s:l:",
while((opt_char = getopt_long(argc, argv, "vd:s:l:h",
long_options, &option_index)) != -1) {
switch (opt_char) {
case 0:
break;
break;
case '?':
case 'h':
usage();
break;
case 'v':