Rsync no longer returns a usage error when used with one local
authorWayne Davison <wayned@samba.org>
Thu, 23 Feb 2006 00:38:34 +0000 (00:38 +0000)
committerWayne Davison <wayned@samba.org>
Thu, 23 Feb 2006 00:38:34 +0000 (00:38 +0000)
source arg and no destination: this now implies the --list-only
option, just like one remote source arg has always done.

main.c

diff --git a/main.c b/main.c
index c82453e..9d8723b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -457,7 +457,7 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
                        flist->count, NS(dest_path));
        }
 
-       if (!dest_path)
+       if (!dest_path || list_only)
                return NULL;
 
        /* If the destination path refers to an existing directory, enter
@@ -960,12 +960,12 @@ static int start_client(int argc, char *argv[])
                return rc;
 
        if (!read_batch) { /* for read_batch, NO source is specified */
-               argc--;
                shell_path = check_for_hostspec(argv[0], &shell_machine, &rsync_port);
                if (shell_path) { /* source is remote */
                        char *dummy1;
                        int dummy2;
-                       if (argc && check_for_hostspec(argv[argc], &dummy1, &dummy2)) {
+                       if (--argc
+                        && check_for_hostspec(argv[argc], &dummy1, &dummy2)) {
                                rprintf(FERROR,
                                        "The source and destination cannot both be remote.\n");
                                exit_cleanup(RERR_SYNTAX);
@@ -990,12 +990,14 @@ static int start_client(int argc, char *argv[])
                } else { /* source is local, check dest arg */
                        am_sender = 1;
 
-                       if (argc < 1) { /* destination required */
-                               usage(FERROR);
-                               exit_cleanup(RERR_SYNTAX);
+                       if (argc > 1)
+                               p = argv[--argc];
+                       else {
+                               p = ".";
+                               list_only = 1;
                        }
 
-                       shell_path = check_for_hostspec(argv[argc], &shell_machine, &rsync_port);
+                       shell_path = check_for_hostspec(p, &shell_machine, &rsync_port);
                        if (shell_path && filesfrom_host && *filesfrom_host
                            && strcmp(filesfrom_host, shell_machine) != 0) {
                                rprintf(FERROR,
@@ -1010,7 +1012,7 @@ static int start_client(int argc, char *argv[])
                                        exit_cleanup(RERR_SYNTAX);
                                }
                                shell_machine = NULL;
-                               shell_path = argv[argc];
+                               shell_path = p;
                        } else if (rsync_port) {
                                if (!shell_cmd) {
                                        return start_socket_client(shell_machine,