--- src/client.c~ Wed Aug 06 13:31:55 2003 +++ src/client.c Mon Nov 17 15:42:50 2003 @@ -4615,6 +4615,35 @@ implementing piped_child)... but I'm doing something else at the moment, and wish to make only one change at a time. -Karl */ +static char **parse_command(char **p, char *cmd) +{ + static char buf[128]; + char *bp = buf; + + while (*cmd) + if (*cmd == '\\' && cmd[1]) { + cmd++; + *bp++ = *cmd == ' ' ? '\1' : *cmd; + cmd++; + } else + *bp++ = *cmd++; + *bp = '\0'; + for (bp=buf ; *bp ;) { + for (; *bp == ' ' ; bp++); + if (*bp) + *p++ = bp; + for (; *bp && *bp != ' ' ; bp++); + if (*bp) + *bp++ = '\2'; + } + for (bp=buf ; *bp ; bp++) + if (*bp == '\1') + *bp = ' '; + else if (*bp == '\2') + *bp = '\0'; + return p; +} + # ifdef START_RSH_WITH_POPEN_RW /* This is actually a crock -- it's OS/2-specific, for no one else @@ -4639,7 +4668,8 @@ int i = 0; /* This needs to fit "rsh", "-b", "-l", "USER", "host", "cmd (w/ args)", and NULL. We leave some room to grow. */ - char *rsh_argv[10]; + char *rsh_argv[15]; + char **p = rsh_argv; if (!cvs_rsh) /* People sometimes suggest or assume that this should default @@ -4667,26 +4697,26 @@ cvs_server = "cvs"; /* The command line starts out with rsh. */ - rsh_argv[i++] = cvs_rsh; + p = parse_command(p, cvs_rsh); # ifdef RSH_NEEDS_BINARY_FLAG /* "-b" for binary, under OS/2. */ - rsh_argv[i++] = "-b"; + *p++ = "-b"; # endif /* RSH_NEEDS_BINARY_FLAG */ /* Then we strcat more things on the end one by one. */ if (root->username != NULL) { - rsh_argv[i++] = "-l"; - rsh_argv[i++] = root->username; + *p++ = "-l"; + *p++ = root->username; } - rsh_argv[i++] = root->hostname; - rsh_argv[i++] = cvs_server; - rsh_argv[i++] = "server"; + *p++ = root->hostname; + *p++ = cvs_server; + *p++ = "server"; /* Mark the end of the arg list. */ - rsh_argv[i] = (char *) NULL; + *p = (char *) NULL; if (trace) { @@ -4740,10 +4770,10 @@ sprintf (command, "%s server", cvs_server); { - char *argv[10]; + char *argv[15]; char **p = argv; - *p++ = cvs_rsh; + p = parse_command(p, cvs_rsh); *p++ = root->hostname; /* If the login names differ between client and server