From ef46c7bb82a86d51cde68de08f0088e7281fc110 Mon Sep 17 00:00:00 2001 From: Todd Lewis Date: Mar 27 2017 22:34:32 +0000 Subject: option -d to include dot files with 6 character names --- diff --git a/hardlink.1 b/hardlink.1 index 04228f4..eca4a1c 100644 --- a/hardlink.1 +++ b/hardlink.1 @@ -3,7 +3,7 @@ hardlink \- Consolidate duplicate files via hardlinks .SH "SYNOPSIS" .PP -\fBhardlink\fP [\fB-c\fP] [\fB-n\fP] [\fB-v\fP] [\fB-vv\fP] [\fB-h\fP] directory1 [ directory2 ... ] +\fBhardlink\fP [\fB-c\fP] [\fB-n\fP] [\fB-d\fP] [\fB-v\fP] [\fB-vv\fP] [\fB-h\fP] directory1 [ directory2 ... ] .SH "DESCRIPTION" .PP This manual page documents \fBhardlink\fP, a @@ -28,6 +28,9 @@ Disregards permission, ownership and other differences. Force hardlinking across file systems. .IP "\fB-n\fP" 10 Do not perform the consolidation; only print what would be changed. +.IP "\fB-d\fP" 10 +Do not skip dot files with six character extensions. The normal behavior +is to skip such files. .IP "\fB-v\fP" 10 Print summary after hardlinking. .IP "\fB-vv\fP" 10 diff --git a/hardlink.c b/hardlink.c index 16d8163..c77029e 100644 --- a/hardlink.c +++ b/hardlink.c @@ -58,6 +58,7 @@ int no_link = 0; int verbose = 0; int content_only = 0; int force = 0; +int dotfiles = 1; typedef struct _f { struct _f *next; @@ -99,12 +100,13 @@ void doexit(int i) void usage(char *prog) { - fprintf (stderr, "Usage: %s [-cnvhf] directories...\n", prog); + fprintf (stderr, "Usage: %s [-cnvhdf] directories...\n", prog); fprintf (stderr, " -c When finding candidates for linking, compare only file contents.\n"); fprintf (stderr, " -n Don't actually link anything, just report what would be done.\n"); fprintf (stderr, " -v Print summary after hardlinking.\n"); fprintf (stderr, " -vv Print every hardlinked file and bytes saved + summary.\n"); fprintf (stderr, " -f Force hardlinking across filesystems.\n"); + fprintf (stderr, " -d Don't skip dot files with 6 char extensions.\n"); fprintf (stderr, " -h Show help.\n"); exit(255); } @@ -329,7 +331,7 @@ int main(int argc, char **argv) int ch; int i; dynstr nam1 = {NULL, 0}; - while ((ch = getopt (argc, argv, "cnvhf")) != -1) { + while ((ch = getopt (argc, argv, "cnvhfd")) != -1) { switch (ch) { case 'n': no_link++; @@ -343,6 +345,9 @@ int main(int argc, char **argv) case 'f': force=1; break; + case 'd': + dotfiles=0; + break; case 'h': default: usage(argv[0]); @@ -375,7 +380,7 @@ int main(int argc, char **argv) if (!di->d_name[1] || !strcmp (di->d_name, "..") || !strncmp (di->d_name, ".in.", 4)) continue; q = strrchr (di->d_name, '.'); - if (q && strlen (q) == 7 && q != di->d_name) { + if (dotfiles && q && strlen (q) == 7 && q != di->d_name) { nam1.buf[nam1baselen] = 0; if (verbose) fprintf(stderr, "Skipping %s%s\n", nam1.buf, di->d_name);