From 15f697c9c7f16c05c8ad8b1a64c857e6baa592e0 Mon Sep 17 00:00:00 2001 From: fredrik Date: Mon, 3 Jul 2006 01:23:29 +0000 Subject: [PATCH] Fix select bug. Select per default, unless -o is given. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@664 959494ce-11ee-0310-bf91-de5d638817bd --- bkselect.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bkselect.c b/bkselect.c index 7912898..3847879 100644 --- a/bkselect.c +++ b/bkselect.c @@ -70,9 +70,11 @@ int bkselect(char *path, int s) if(bkselect(pb, s)) r = 1; } else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) { - if(s && printnames) - printf("%s\n", pb); - tsize += sb.st_size; + if(s) { + if(printnames) + printf("%s\n", pb); + tsize += sb.st_size; + } } } @@ -82,14 +84,15 @@ int bkselect(char *path, int s) void usage(void) { - fprintf(stderr, "usage: bkselect [-hsq] path...\n"); + fprintf(stderr, "usage: bkselect [-hsqo] path...\n"); } int main(int argc, char **argv) { - int c, i, r; + int c, i, r, s; - while((c = getopt(argc, argv, "hsq")) >= 0) { + s = 1; + while((c = getopt(argc, argv, "hsqo")) >= 0) { switch(c) { case 's': printsize = 1; @@ -97,6 +100,9 @@ int main(int argc, char **argv) case 'q': printnames = 0; break; + case 'o': + s = 0; + break; case 'h': default: usage(); @@ -109,7 +115,7 @@ int main(int argc, char **argv) } r = 0; for(i = optind; i < argc; i++) { - if(bkselect(argv[i], 0)) + if(bkselect(argv[i], s)) r = 1; } if(printsize) -- 2.11.0