+static int run_command(int argc, char *argv[]) {
+ if(optind >= argc) {
+ return cmd_shell(argc, argv);
+ }
+
+ for(int i = 0; commands[i].command; i++) {
+ if(!strcasecmp(argv[optind], commands[i].command)) {
+ return commands[i].function(argc - optind, argv + optind);
+ }
+ }
+
+ fprintf(stderr, "Unknown command `%s'.\n", argv[optind]);
+ usage(true);
+ return 1;
+}
+