mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 05:56:03 +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:
parent
beac0b49e4
commit
aa97c4f9f2
1 changed files with 4 additions and 1 deletions
|
|
@ -30,17 +30,20 @@ TracerConfig parseCmdLine(int argc, char** argv)
|
||||||
{ "socket_path", required_argument, 0, 'l' },
|
{ "socket_path", required_argument, 0, 'l' },
|
||||||
{ "store_dir", required_argument, 0, 's' },
|
{ "store_dir", required_argument, 0, 's' },
|
||||||
{ "state_dir", required_argument, 0, 'd' },
|
{ "state_dir", required_argument, 0, 'd' },
|
||||||
|
{ "help", no_argument, 0, 'h' },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
int opt_char;
|
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) {
|
long_options, &option_index)) != -1) {
|
||||||
switch (opt_char) {
|
switch (opt_char) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
|
case 'h':
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue