shell-command-to-string: Store temporary file in TMP: or in (USER-HOMEDIR-PATHNAME).

Pascal J. Bourguignon [2020-10-28 09:07]
shell-command-to-string: Store temporary file in TMP: or in (USER-HOMEDIR-PATHNAME).
Filename
tools/manifest.lisp
diff --git a/tools/manifest.lisp b/tools/manifest.lisp
index 29e7ea9..45a8c5f 100644
--- a/tools/manifest.lisp
+++ b/tools/manifest.lisp
@@ -118,8 +118,14 @@
 (defun shell-command-to-string (command &rest arguments)
   "Execute the COMMAND with asdf:run-shell-command and returns its
 stdout in a string (going thru a file)."
-  (let ((*default-pathname-defaults* #P"")
-        (path (format nil "~:@(out-~36,8,'0R.txt~)" (random (expt 2 32)))))
+  (let* ((*default-pathname-defaults* #P"")
+         (name (format nil "~:@(OUT-~36,8,'0R~)" (random (expt 2 32))))
+         (path (namestring (translate-logical-pathname
+                            (if (ignore-errors (logical-pathname-translations "TMP"))
+                                (make-pathname :host "TMP" :directory '(:absolute)
+                                               :name name :type "TXT")
+                                (merge-pathnames (user-homedir-pathname)
+                                                 (make-pathname :name name :type "TXT")))))))
     (unwind-protect
          (when (zerop (asdf:run-shell-command (format nil "~? > ~S" command arguments path)))
            (with-output-to-string (out)
@@ -130,7 +136,6 @@ stdout in a string (going thru a file)."
       (ignore-errors (delete-file path)))))


-
 (defun prepare-options (options)
   (mapcar (lambda (option)
             (typecase option
ViewGit