     (setq shell-args (list shell-args)))
   (when (stringp utils)
     (setq utils (list utils)))
+  (when (or gen-temp-dir (string-match-p "\<\<td\>\>" script 0))
+    (setq gen-temp-dir (make-temp-file "dwim-shell-command-" t)))
   (let* ((proc-buffer (generate-new-buffer buffer-name))
          (template script)
          (script "")

      (set-process-sentinel proc #'dwim-shell-command--sentinel)
      (set-process-filter proc #'dwim-shell-command--filter))))

(defun dwim-shell-command--expand (template file &optional post-process-template)
  "Expand TEMPLATE using FILE.

Expand using <<f>> for FILE, <<fne>> for FILE without extension, and

  (dwim-shell-command-on-marked-files
   "DWIM shell command" (read-shell-command "DWIM shell command: ")))

(cl-defun dwim-shell-command-execute-script (buffer-name script &key files extensions shell-util shell-args shell-pipe utils post-process-template on-completion silent-success gen-temp-dir)
  "Execute a script asynchronously, DWIM style with SCRIPT and BUFFER-NAME.

:FILES are used to instantiate SCRIPT as a  noweb template.
