- for (i = argc - orig_argc; i < argc; i++) {
- /* FIXME: This apparently crashes if rsync is run with
- * just "rsync -F". I think directly manipulating
- * argv[] is probably bogus -- what if -F is part of a
- * run of several short options? */
- if (!strcmp(argv[i], "-F")) { /* safer to change it here than script */
- strncat(buff, "-f ", 3); /* chg to -f + ext to get ready for remote */
- strncat(buff, batch_file_ext,
- strlen(batch_file_ext));
- } else {
- strncat(buff, argv[i], strlen(argv[i]));
+ for (i = 0; i < argc; ++i) {
+ if (i == argc - 2) /* Skip source directory on cmdline */
+ continue;
+ /*
+ * FIXME:
+ * I think directly manipulating argv[] is probably bogus
+ */
+ if (!strncmp(argv[i], "--write-batch",
+ strlen("--write-batch"))) {
+ /* Safer to change it here than script */
+ /*
+ * Change to --read-batch=prefix
+ * to get ready for remote
+ */
+ strlcat(buff, "--read-batch=", sizeof(buff));
+ strlcat(buff, batch_prefix, sizeof(buff));
+ } else
+ if (i == argc - 1) {
+ snprintf(buff2, sizeof(buff2), "${1:-%s}", argv[i]);
+ strlcat(buff, buff2, sizeof(buff));
+ }
+ else {
+ strlcat(buff, argv[i], sizeof(buff));