-#if SHELL_ESCAPE
- case A_SHELL:
- /*
- * !! just uses whatever is in shellcmd.
- * Otherwise, copy cmdbuf to shellcmd,
- * replacing any '%' with the current
- * file name.
- */
- if (*cmdbuf != '!')
- {
- register char *fr, *to;
-
- /*
- * Make one pass to see how big a buffer we
- * need to allocate for the expanded shell cmd.
- */
- for (fr = cmdbuf; *fr != '\0'; fr++)
- if (*fr == '%')
- n += strlen(current_file);
- else
- n++;
-
- if (shellcmd != NULL)
- free(shellcmd);
- shellcmd = calloc(n+1, sizeof(char));
- if (shellcmd == NULL)
- {
- error("cannot allocate memory");
- break;
- }
-
- /*
- * Now copy the shell cmd, expanding any "%"
- * into the current filename.
- */
- to = shellcmd;
- for (fr = cmdbuf; *fr != '\0'; fr++)
- {
- if (*fr != '%')
- *to++ = *fr;
- else
- {
- strcpy(to, current_file);
- to += strlen(to);
- }
- }
- *to = '\0';
- }
-
- if (shellcmd == NULL)
- lsystem("");
- else
- lsystem(shellcmd);
- error("!done");
- break;
-#endif