On Sun, Jul 15, 2012 at 02:54:31PM +0200, Jan Klemkow wrote:
> +                     if (!mflag)
> +                             continue;
> +                     if (depth == max_depth)
> +                             continue;

This breaks the non recursive case.  There depth and max_depth are
always 0.  Do "if (S_ISDIR(filestat.st_mode) && depth == max_depth)"
as I have already suggested.

> +                     if (!confirm(argv[0], *cpp))
> +                             continue;
> +
> +                     /*
> +                      * If file is a directory then create a new one
> +                      * at the remote machine.
> +                      */
> +                     stat(*cpp, &filestat);

Please do the error check.

> +                     if (S_ISDIR(filestat.st_mode)) {
> +                             xargv[1] = *cpp;
> +                             makedir(2, xargv);
> +                             cd(2, xargv);
> +                             if (dirchange != 1) {
> +                                     warn("remote: %s", *cpp);
> +                                     mflag = 0;

mget does not set mflag = 0 here.  If we cannot create a remote
directory, just print the error message and skip this file.
Don't stop recursion.

> +                                     continue;
> +                             }
> +
> +                             if (chdir(*cpp) != 0) {
> +                                     warn("local: %s", *cpp);

mget does not warn here.  This should not happen anyway.  But perhaps
it would be better to add a warning in mget than to remove it here.

> +                                     goto out;
> +                             }
> +
> +                             /* Copy the whole directory recursively. */
> +                             xargv[1] = "*";
> +                             mput(2, xargv);
> +
> +                             if (chdir("..") != 0) {
> +                                     warn("local: %s", *cpp);

mget does not warn here.  This should not happen anyway.

> +                                     mflag = 0;

mget has a goto out here.  Of course that does not change anything.
But it shows that the correct error handling has been considered.

> +                             }
> + out:
> +                             xargv[1] = "..";
> +                             cd(2, xargv);
> +                             if (dirchange != 1) {
> +                                     warn("remote: %s", *cpp);
> +                                     mflag = 0;
>                               }
> +                             continue;
> +                     }

bluhm

Reply via email to