MCPcopy Index your code
hub / github.com/RsyncProject/rsync / write_arg

Function write_arg

batch.c:164–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164static int write_arg(const char *arg)
165{
166 const char *x, *s;
167 int len, err = 0;
168
169 if (*arg == '-' && (x = strchr(arg, '=')) != NULL) {
170 err |= write(batch_sh_fd, arg, x - arg + 1) != x - arg + 1;
171 arg += x - arg + 1;
172 }
173
174 if (strpbrk(arg, " \"'&;|[]()$#!*?^\\") != NULL) {
175 err |= write(batch_sh_fd, "'", 1) != 1;
176 for (s = arg; (x = strchr(s, '\'')) != NULL; s = x + 1) {
177 err |= write(batch_sh_fd, s, x - s + 1) != x - s + 1;
178 err |= write(batch_sh_fd, "'", 1) != 1;
179 }
180 len = strlen(s);
181 err |= write(batch_sh_fd, s, len) != len;
182 err |= write(batch_sh_fd, "'", 1) != 1;
183 return err;
184 }
185
186 len = strlen(arg);
187 err |= write(batch_sh_fd, arg, len) != len;
188
189 return err;
190}
191
192/* Writes out a space and then an option (or other string) with an optional "=" + arg suffix. */
193static int write_opt(const char *opt, const char *arg)

Callers 2

write_optFunction · 0.85
write_batch_shell_fileFunction · 0.85

Calls 1

strpbrkFunction · 0.85

Tested by

no test coverage detected