2fad00ff40d1dfc4f88cf7e93ca3495d8dfb897d — Simon Ser 25 days ago 5f018e1
builtin/command: refuse -V's unspecified output format
1 files changed, 7 insertions(+), 5 deletions(-)

M builtin/command.c
M builtin/command.c => builtin/command.c +7 -5
@@ 57,18 57,20 @@ while ((opt = mrsh_getopt(argc, argv, ":vVp")) != -1) {
  		switch (opt) {
  		case 'v':
- 			if (argc != 3) {
+ 			if (mrsh_optind < argc) {
+ 				fprintf(stderr, command_usage);
  				return 1;
  			}
  			return command_v(state, argv[mrsh_optind]);
  		case 'V':
+ 			fprintf(stderr, "command: `-V` has an unspecified output format, "
+ 				"use `-v` instead\n");
+ 			return 0;
  		case 'p':
- 			fprintf(stderr, "command: `-V` and `-p` and no arg not "
- 					"yet implemented\n");
+ 			fprintf(stderr, "command: `-p` not yet implemented\n");
  			return 1;
  		default:
- 			fprintf(stderr, "command: unknown option -- %c\n",
- 					mrsh_optopt);
+ 			fprintf(stderr, "command: unknown option -- %c\n", mrsh_optopt);
  			fprintf(stderr, command_usage);
  			return 1;
  		}