X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=finddup.c;h=91079de97a4dd016709e4cefc629f1bc1b7ae15b;hb=b1122ce4f579824cd5182f5bdd1f5c780c652d3b;hp=39a3df6c22b733d34ed88a5041fbf9ac3b170c93;hpb=87eea2c3b5958b578cdf32f5e01d3c733bdf7615;p=finddup.git diff --git a/finddup.c b/finddup.c index 39a3df6..91079de 100644 --- a/finddup.c +++ b/finddup.c @@ -22,6 +22,8 @@ * */ +#define VERSION_NUMBER "0.5" + #define _BSD_SOURCE #include @@ -219,9 +221,9 @@ void start(const char *dirname1, const char *dirname2) { struct file_with_size *node1, *node2; int not_in, found; - if(dirname2[0] == '^') { + if(strncmp(dirname2, "not:", 4) == 0) { not_in = 1; - dirname2++; + dirname2 += 4; } else { not_in = 0; } @@ -269,6 +271,17 @@ void start(const char *dirname1, const char *dirname2) { file_list_delete(list2); } +void print_help(FILE *out) { + fprintf(out, "Usage: finddup [OPTION]... DIR1 [[not:]DIR2]\n"); + fprintf(out, "Version %s (%s)\n", VERSION_NUMBER, UNAME); + fprintf(out, "Without DIR2, lists duplicate files found in DIR1. With DIR2, lists files common to both directories. With the not: prefix, lists files found in DIR1 which do not exist in DIR2.\n"); + fprintf(out, "\n"); + fprintf(out, " -h show this help.\n"); + fprintf(out, " -r show the real file paths.\n"); + fprintf(out, "\n"); + fprintf(out, "Report bugs and comments to \n"); +} + /**********************************************************************/ int main(int argc, char **argv) { @@ -287,8 +300,7 @@ int main(int argc, char **argv) { switch (c) { case 'h': - printf("Usage: finddup [OPTION]... [FILE]...\n"); - printf("Report bugs and comments to \n"); + print_help(stdout); exit(EXIT_SUCCESS); break; @@ -307,7 +319,7 @@ int main(int argc, char **argv) { } else if(optind < argc) { start(argv[optind], argv[optind]); } else { - fprintf(stderr, "%s [OPTIONS] [[^]]\n", argv[0]); + print_help(stderr); exit(EXIT_FAILURE); }