- if (i < n) { /* commands left unchecked */
- if (i == 0) { /* root command */
- printf("unknown command\n");
- } else if (cur->sub != NULL) { /* intermediate command */
- printf("unknown %s subcommand\n", com[i - 1]);
- } else if (!cur->hasArgs) { /* terminal command without arguments */
- printf("%s as no subcommand and takes no parameter\n", com[i - 1]);
- } else if (cur->comfunc == NULL) { /* erroneous terminal command without function */
- printf("terminal command without function\n");
- } else { /* terminal command with arguments, left "commands" are in fact parameters */
- cur->comfunc(n - i, (const char**)&com[i], nga);
- }
- } else { /* no command left */
- if (cur->sub != NULL) { /* intermediate command */
+ if (cur->sub != NULL) {
+ /* not terminal command */
+ if (i == 0) {
+ /* root command */
+ printf("unknown command: %s\n", com[i]);
+ } else if (i < n) {
+ /* intermediate command, remaining string */
+ printf("unknown %s subcommand: %s\n", com[i - 1], com[i]);
+ } else {
+ /* intermediate command, no remaining string */