aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-08-14 18:08:44 -0400
committerDave Reisner <dreisner@archlinux.org>2012-08-14 18:09:29 -0400
commit7911dbe2226e3f177fb92d4028844cafda847655 (patch)
treea0228d3aa16f77cdbb8cdebcc721aef25c5b9e83
parent8892501d68902c7d5bf14824a4f3904ccd4e2577 (diff)
downloadmirror-ponymix-7911dbe2226e3f177fb92d4028844cafda847655.tar.gz
mirror-ponymix-7911dbe2226e3f177fb92d4028844cafda847655.tar.bz2
mirror-ponymix-7911dbe2226e3f177fb92d4028844cafda847655.zip
fix option handling. oops
-rw-r--r--ponymix.c12
1 files changed, 7 insertions, 5 deletions
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: