Skip to content

Commit

Permalink
Merge to update uniq fixing the segfault when no args are given.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavidsmith committed Jun 24, 2023
2 parents 18cb3cf + 5392a1e commit f2d548a
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/utils/uniq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,25 +317,18 @@ main_uniq(int argc, const char **argv) {
opt_parse.set_show_defaults();
vector<string> leftover_args;
opt_parse.parse(argc, argv, leftover_args);
if (opt_parse.help_requested()) {
if (opt_parse.about_requested() || opt_parse.help_requested() ||
leftover_args.empty()) {
cerr << opt_parse.help_message() << endl
<< opt_parse.about_message() << endl;
return EXIT_SUCCESS;
}
if (opt_parse.about_requested()) {
cerr << opt_parse.about_message() << endl;
return EXIT_SUCCESS;
}
if (opt_parse.option_missing()) {
cerr << opt_parse.option_missing_message() << endl;
return EXIT_SUCCESS;
}
if (leftover_args.size() == 1 && !use_stdout) {
cerr << opt_parse.help_message() << endl
<< opt_parse.about_message() << endl;
return EXIT_SUCCESS;
}
if (leftover_args.size() == 2 && use_stdout) {
if ((leftover_args.size() == 1 && !use_stdout) ||
(leftover_args.size() == 2 && use_stdout)) {
cerr << opt_parse.help_message() << endl
<< opt_parse.about_message() << endl;
return EXIT_SUCCESS;
Expand Down

0 comments on commit f2d548a

Please sign in to comment.