Add --quiet/-q option. Contributed by Rich Salz salzr@certco.com.
authorDavid Dykstra <dwd@samba.org>
Tue, 9 Feb 1999 17:25:35 +0000 (17:25 +0000)
committerDavid Dykstra <dwd@samba.org>
Tue, 9 Feb 1999 17:25:35 +0000 (17:25 +0000)
clientserver.c
log.c
main.c
options.c
rsync.yo

index 7b0dd16..a429b8d 100644 (file)
@@ -292,7 +292,7 @@ static int rsync_module(int fd, int i)
                }
        }
 
-       ret = parse_arguments(argc, argv);
+       ret = parse_arguments(argc, argv, 0);
 
        if (request) {
                if (*auth_user) {
diff --git a/log.c b/log.c
index 3643df7..6239409 100644 (file)
--- a/log.c
+++ b/log.c
@@ -87,8 +87,11 @@ void log_open(void)
        int len;
        FILE *f=NULL;
        extern int am_daemon;
+       extern int quiet;
        /* recursion can happen with certain fatal conditions */
 
+       if (quiet != 0 && fd == FINFO) return;
+
        va_start(ap, format);
        len = vslprintf(buf, sizeof(buf), format, ap);
        va_end(ap);
diff --git a/main.c b/main.c
index 8740557..c46de2a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -592,7 +592,7 @@ int main(int argc,char *argv[])
           carried across */
        orig_umask = (int)umask(0);
 
-       if (!parse_arguments(argc, argv)) {
+       if (!parse_arguments(argc, argv, 1)) {
                exit_cleanup(RERR_SYNTAX);
        }
 
index 19ff7ef..9935617 100644 (file)
--- a/options.c
+++ b/options.c
@@ -72,6 +72,7 @@ char *rsync_path = RSYNC_NAME;
 int rsync_port = RSYNC_PORT;
 
 int verbose = 0;
+int quiet = 0;
 int always_checksum = 0;
 int list_only = 0;
 
@@ -90,6 +91,7 @@ void usage(int F)
   rprintf(F,"  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");
   rprintf(F,"\nOptions\n");
   rprintf(F," -v, --verbose               increase verbosity\n");
+  rprintf(F," -q, --quiet                 decrease verbosity\n");
   rprintf(F," -c, --checksum              always checksum\n");
   rprintf(F," -a, --archive               archive mode\n");
   rprintf(F," -r, --recursive             recurse into directories\n");
@@ -151,7 +153,7 @@ enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
       OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS,
       OPT_SAFE_LINKS, OPT_COMPARE_DEST, OPT_LOG_FORMAT,OPT_PASSWORD_FILE};
 
-static char *short_options = "oblLWHpguDCtcahvrRIxnSe:B:T:z";
+static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:z";
 
 static struct option long_options[] = {
   {"version",     0,     0,    OPT_VERSION},
@@ -177,6 +179,7 @@ static struct option long_options[] = {
   {"backup",      0,     0,    'b'},
   {"update",      0,     0,    'u'},
   {"verbose",     0,     0,    'v'},
+  {"quiet",       0,     0,    'q'},
   {"recursive",   0,     0,    'r'},
   {"relative",    0,     0,    'R'},
   {"devices",     0,     0,    'D'},
@@ -249,7 +252,7 @@ static int check_refuse_options(char *ref, int opt)
 }
 
 
-int parse_arguments(int argc, char *argv[])
+int parse_arguments(int argc, char *argv[], int frommain)
 {
        int opt;
        int option_index;
@@ -395,6 +398,10 @@ int parse_arguments(int argc, char *argv[])
                        verbose++;
                        break;
 
+               case 'q':
+                       if (frommain) quiet++;
+                       break;
+
                case 'a':
                        recurse=1;
 #if SUPPORT_LINKS
@@ -507,6 +514,7 @@ void server_options(char **args,int *argc)
        argstr[0] = '-';
        for (i=0;i<verbose;i++)
                argstr[x++] = 'v';
+       /* the -q option is intentionally left out */
        if (make_backups)
                argstr[x++] = 'b';
        if (update_only)
index 80ac10b..db4c2b2 100644 (file)
--- a/rsync.yo
+++ b/rsync.yo
@@ -1,5 +1,5 @@
 mailto(rsync-bugs@samba.org)
-manpage(rsync)(1)(7 Jan 1999)()()
+manpage(rsync)(1)(9 Feb 1999)()()
 manpagename(rsync)(faster, flexible replacement for rcp)
 manpagesynopsis()
 
@@ -220,6 +220,7 @@ Usage: rsync [OPTION]... SRC [USER@]HOST:DEST
 
 Options
  -v, --verbose               increase verbosity
+ -q, --quiet                 decrease verbosity
  -c, --checksum              always checksum
  -a, --archive               archive mode
  -r, --recursive             recurse into directories
@@ -288,6 +289,11 @@ information on what files are being skipped and slightly more
 information at the end. More than two -v flags should only be used if
 you are debugging rsync.
 
+dit(bf(-q, --quiet)) This option decreases the amount of information you
+are given during the transfer, notably suppressing information messages
+from the remote server. This flag is useful when invoking rsync from
+cron.
+
 dit(bf(-I, --ignore-times)) Normally rsync will skip any files that are
 already the same length and have the same time-stamp. This option turns
 off this behavior.