+static void write_arg(int fd, char *arg)
+{
+ char *x, *s;
+
+ if (*arg == '-' && (x = strchr(arg, '=')) != NULL) {
+ write(fd, arg, x - arg + 1);
+ arg += x - arg + 1;
+ }
+
+ if (strpbrk(arg, " \"'&;|[]()$#!*?^\\") != NULL) {
+ write(fd, "'", 1);
+ for (s = arg; (x = strchr(s, '\'')) != NULL; s = x + 1) {
+ write(fd, s, x - s + 1);
+ write(fd, "'", 1);
+ }
+ write(fd, s, strlen(s));
+ write(fd, "'", 1);
+ return;
+ }
+
+ write(fd, arg, strlen(arg));
+}
+
+/* This routine tries to write out an equivalent --read-batch command
+ * given the user's --write-batch args. However, it doesn't really
+ * understand most of the options, so it uses some overly simple
+ * heuristics to munge the command line into something that will
+ * (hopefully) work. */
+void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)