* Find a command */
| 522 | * Find a command |
| 523 | */ |
| 524 | static const struct ngcmd * |
| 525 | FindCommand(const char *string) |
| 526 | { |
| 527 | int k, found = -1; |
| 528 | |
| 529 | for (k = 0; cmds[k] != NULL; k++) { |
| 530 | if (MatchCommand(cmds[k], string)) { |
| 531 | if (found != -1) { |
| 532 | warnx("\"%s\": ambiguous command", string); |
| 533 | return (NULL); |
| 534 | } |
| 535 | found = k; |
| 536 | } |
| 537 | } |
| 538 | if (found == -1) { |
| 539 | warnx("\"%s\": unknown command", string); |
| 540 | return (NULL); |
| 541 | } |
| 542 | return (cmds[found]); |
| 543 | } |
| 544 | |
| 545 | /* |
| 546 | * See if string matches a prefix of "cmd" (or an alias) case insensitively |
no test coverage detected