From 3b18234b6b9247f6e5943af0fca8d3fc0b50b593 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Thu, 2 Aug 2007 22:14:37 -0700 Subject: [PATCH] Print a help message if no paths are specified to back up. Rather than defaulting to backing up the current directory, always require that a path be specified. If no paths are specified, print the usage message and exit. Also, fix a crash that previously occurred when no paths were specified. --- scandir.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scandir.cc b/scandir.cc index db0961b..841dc91 100644 --- a/scandir.cc +++ b/scandir.cc @@ -572,7 +572,6 @@ void usage(const char *program) int main(int argc, char *argv[]) { - string backup_source = "."; string backup_dest = ""; string localdb_dir = ""; string backup_scheme = ""; @@ -627,15 +626,14 @@ int main(int argc, char *argv[]) } } - searches.push_back("."); if (optind == argc) { - add_include("."); - } else { - for (int i = optind; i < argc; i++) - add_include(argv[i]); + usage(argv[0]); + return 1; } - backup_source = argv[optind]; + searches.push_back("."); + for (int i = optind; i < argc; i++) + add_include(argv[i]); if (backup_dest == "") { fprintf(stderr, -- 2.20.1