Skip to content

Commit

Permalink
fixup show unknown option error messages better for short options
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed May 13, 2024
1 parent 04a5f1d commit 7f2e2ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,8 +1595,9 @@ int main(int argc, const char **argv)
if(!o.end_of_options && argv[0][0] == '-') {
/* dash-dash prefixed */
if(getarg(&o, argv[0], argv[1], &usedarg)) {
/* if the option ends with an equals sign, cut it there */
size_t not_e = strcspn(argv[0], "=");
/* if the long option ends with an equals sign, cut it there,
if it is a short option, show just two letters */
size_t not_e = argv[0][1] == '-' ? strcspn(argv[0], "=") : 2;
errorf(&o, ERROR_FLAG, "unknown option: %.*s", (int)not_e, argv[0]);
}
}
Expand Down

0 comments on commit 7f2e2ba

Please sign in to comment.