summaryrefslogtreecommitdiffstats
path: root/tools/lvm.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2002-12-05 22:35:15 +0000
committerAlasdair Kergon <agk@redhat.com>2002-12-05 22:35:15 +0000
commit987c4c151995e3ee7188da26f4f3b5c8e05f2b7a (patch)
treed7a576e5b4ec865cddc2ebe0831a97facc1a706d /tools/lvm.c
parent8a95d67e26d49418b2324333bfb85bafea86b990 (diff)
downloadlvm2-987c4c151995e3ee7188da26f4f3b5c8e05f2b7a.tar.gz
lvm2-987c4c151995e3ee7188da26f4f3b5c8e05f2b7a.tar.xz
lvm2-987c4c151995e3ee7188da26f4f3b5c8e05f2b7a.zip
Fix long arg processing.
Diffstat (limited to 'tools/lvm.c')
-rw-r--r--tools/lvm.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/lvm.c b/tools/lvm.c
index 7377f952..dbc295ff 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -360,9 +360,7 @@ void usage(const char *name)
* is no short argument then the index of the
* argument in the the_args array is set as the
* long opt value. Yuck. Of course this means we
- * can't have more than 'a' long arguments. Since
- * we have only 1 ATM (--version) I think we can
- * live with this restriction.
+ * can't have more than 'a' long arguments.
*/
static void _add_getopt_arg(int arg, char **ptr, struct option **o)
{
@@ -379,7 +377,10 @@ static void _add_getopt_arg(int arg, char **ptr, struct option **o)
(*o)->name = a->long_arg + 2;
(*o)->has_arg = a->fn ? 1 : 0;
(*o)->flag = NULL;
- (*o)->val = arg;
+ if (a->short_arg)
+ (*o)->val = a->short_arg;
+ else
+ (*o)->val = arg;
(*o)++;
}
}
@@ -434,6 +435,9 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
optind = 0;
while ((opt = getopt_long(*argc, *argv, str, opts, NULL)) >= 0) {
+ if (opt == '?')
+ return 0;
+
a = _find_arg(cmd->command, opt);
if (!a) {
@@ -1146,5 +1150,7 @@ int main(int argc, char **argv)
out:
_fin(cmd);
+ if (ret == ECMD_PROCESSED)
+ ret = 0;
return ret;
}