extern int inplace;
extern int append_mode;
extern int write_batch;
+extern int xfersum_type;
extern int protocol_version;
extern int raw_argc, cooked_argc;
extern char **raw_argv, **cooked_argv;
* (hopefully) work. */
void write_batch_shell_file(void)
{
- int i, len, err = 0;
+ int i, j, len, err = 0;
char *p, *p2;
/* Write argvs info to BATCH.sh file */
* do a string-based negotation (since we don't write them into the file). */
if (do_compression)
err |= write_opt("--compress-choice", compress_choice);
- err |= write_opt("--checksum-choice", checksum_choice);
+ if (strchr(checksum_choice, ',') || xfersum_type != parse_csum_name(NULL, -1))
+ err |= write_opt("--checksum-choice", checksum_choice);
+
+ /* Elide the filename args from the option list, but scan for them in reverse. */
+ for (i = raw_argc-1, j = cooked_argc-1; i > 0 && j >= 0; i--) {
+ if (strcmp(raw_argv[i], cooked_argv[j]) == 0) {
+ raw_argv[i] = NULL;
+ j--;
+ }
+ }
for (i = 1; i < raw_argc; i++) {
- p = raw_argv[i];
- if (cooked_argc && p[0] == cooked_argv[0][0] && strcmp(p, cooked_argv[0]) == 0) {
- cooked_argv++;
- cooked_argc--;
+ if (!(p = raw_argv[i]))
continue;
- }
if (strncmp(p, "--files-from", 12) == 0
|| strncmp(p, "--filter", 8) == 0
|| strncmp(p, "--include", 9) == 0
int xfersum_type = 0; /* used for the file transfer checksums */
int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
-static int parse_csum_name(const char *name, int len)
+int parse_csum_name(const char *name, int len)
{
struct name_num_item *nni;
option_error();
exit_cleanup(RERR_SYNTAX);
}
- cooked_argc = argc;
- cooked_argv = argv;
+ if (write_batch) {
+ int j;
+ cooked_argc = argc;
+ cooked_argv = new_array(char*, argc+1);
+ for (j = 0; j <= argc; j++)
+ cooked_argv[j] = argv[j];
+ }
SIGACTMASK(SIGINT, sig_int);
SIGACTMASK(SIGHUP, sig_int);