| 162 | } |
| 163 | |
| 164 | static 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. */ |
| 193 | static int write_opt(const char *opt, const char *arg) |
no test coverage detected