summaryrefslogtreecommitdiff
path: root/udevtrigger.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2006-08-21 02:38:20 +0200
committerKay Sievers <kay.sievers@suse.de>2006-08-21 02:38:20 +0200
commite3396a2d383cf19092911a4643e092f6a825b2aa (patch)
tree8b002d91b5af5b243d1bb623c22309a2e3c96cf4 /udevtrigger.c
parentc4edd0adb55ebf625a0f190071b930b469c58dd8 (diff)
cleanup commandline argument handling
Print and log failure, but don't fail for tools which are usually not used iteractively. Add '--help' to all tools.
Diffstat (limited to 'udevtrigger.c')
-rw-r--r--udevtrigger.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/udevtrigger.c b/udevtrigger.c
index 9345a06ab7..e530a61c0b 100644
--- a/udevtrigger.c
+++ b/udevtrigger.c
@@ -359,6 +359,7 @@ static void scan_failed(void)
int main(int argc, char *argv[], char *envp[])
{
int i;
+ int failed = 0;
logging_init("udevtrigger");
udev_config_init();
@@ -373,19 +374,24 @@ int main(int argc, char *argv[], char *envp[])
} else if (strcmp(arg, "--dry-run") == 0 || strcmp(arg, "-n") == 0) {
dry_run = 1;
} else if (strcmp(arg, "--retry-failed") == 0 || strcmp(arg, "-F") == 0) {
- scan_failed();
- exec_lists();
+ failed = 1;
+ } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
+ printf("Usage: udevtrigger [--help] [--verbose] [--dry-run] [--retry-failed]\n");
goto exit;
} else {
- fprintf(stderr, "Usage: udevtrigger [--verbose] [--dry-run] [--retry-failed]\n");
- goto exit;
+ fprintf(stderr, "unrecognized option '%s'\n", arg);
+ err("unrecognized option '%s'\n", arg);
}
}
- /* default action */
- scan_bus();
- scan_class();
- scan_block();
+ if (failed)
+ scan_failed();
+ else {
+ /* default action */
+ scan_bus();
+ scan_class();
+ scan_block();
+ }
exec_lists();
exit: