diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-08-14 18:08:44 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-08-14 18:09:29 -0400 |
commit | 7911dbe2226e3f177fb92d4028844cafda847655 (patch) | |
tree | a0228d3aa16f77cdbb8cdebcc721aef25c5b9e83 | |
parent | 8892501d68902c7d5bf14824a4f3904ccd4e2577 (diff) | |
download | mirror-ponymix-7911dbe2226e3f177fb92d4028844cafda847655.tar.gz mirror-ponymix-7911dbe2226e3f177fb92d4028844cafda847655.tar.bz2 mirror-ponymix-7911dbe2226e3f177fb92d4028844cafda847655.zip |
fix option handling. oops
-rw-r--r-- | ponymix.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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: |