From 7911dbe2226e3f177fb92d4028844cafda847655 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 14 Aug 2012 18:08:44 -0400 Subject: fix option handling. oops --- ponymix.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'ponymix.c') diff --git a/ponymix.c b/ponymix.c index cf2467f..8445f97 100644 --- a/ponymix.c +++ b/ponymix.c @@ -775,16 +775,18 @@ int main(int argc, char *argv[]) } } - /* string -> enum */ - verb = string_to_verb(argv[optind]); + if (optind == argc) + verb = mode == MODE_DEVICE ? ACTION_LIST : ACTION_DEFAULTS; + else + verb = string_to_verb(argv[optind++]); + if (verb == ACTION_INVALID) errx(EXIT_FAILURE, "unknown action: %s", argv[optind]); - if (actions[verb].argreq != (argc - optind - 1)) + if (actions[verb].argreq != (argc - optind)) errx(EXIT_FAILURE, "wrong number of args for %s command (requires %d)", - argv[optind], actions[verb].argreq); + argv[optind - 1], actions[verb].argreq); - optind++; switch (verb) { case ACTION_SETVOL: case ACTION_SETBAL: -- cgit v1.2.3