From ee1830574683cc54cfd714492920e3171b167360 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 8 Aug 2010 05:24:47 +0000 Subject: make disklabel -p slightly nicer by accepting capital letters and printing a more useful error message for invalid ones. ok deraadt --- sbin/disklabel/disklabel.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index acc149d61f0..368d2f3ed2b 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.169 2010/08/03 00:19:42 krw Exp $ */ +/* $OpenBSD: disklabel.c,v 1.170 2010/08/08 05:24:46 tedu Exp $ */ /* * Copyright (c) 1987, 1993 @@ -188,10 +188,12 @@ main(int argc, char *argv[]) op = WRITE; break; case 'p': - if (strchr("bckmgt", optarg[0]) == NULL || - optarg[1] != '\0') - usage(); - print_unit = optarg[0]; + if (strchr("bckmgtBCKMGT", optarg[0]) == NULL || + optarg[1] != '\0') { + fprintf(stderr, "Valid units are bckmgt\n"); + exit(1); + } + print_unit = tolower(optarg[0]); break; case 'n': donothing++; -- cgit v1.2.3