From b0b8a8bcc07d0993a8d7cf008a3e69fdfaa5dab7 Mon Sep 17 00:00:00 2001 From: Francois-Rene Rideau <tunes@google.com> Date: Wed, 1 Jan 2014 17:25:01 -0500 Subject: [PATCH] Fix the default suffix and type of with-temporary-file. Fix the the handling of :directory in run-program when using system. --- test/test-sysdef-asdf.script | 6 ++++-- uiop/run-program.lisp | 3 ++- uiop/stream.lisp | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/test-sysdef-asdf.script b/test/test-sysdef-asdf.script index 6fa49bfe..856ca3cd 100644 --- a/test/test-sysdef-asdf.script +++ b/test/test-sysdef-asdf.script @@ -13,15 +13,17 @@ (defun system-lisp-files (system) (loop :for f :in (required-components system :keep-component 'cl-source-file) - :collect (enough-namestring (component-pathname f) *asdf-directory*))) + :collect (namestring (enough-pathname (component-pathname f) *asdf-directory*)))) (defun makefile-lisp-files (target) (remove-if 'emptyp - (split-string + (split-string ;; NB: assumes GNU make (run-program `("make" "--quiet" "--no-print-directory" ,target) :output :string :error-output t :directory *asdf-directory*) :separator #(#\space #\newline #\return #\tab)))) +#+clisp (trace run-program reduce/strcat) + (defmacro compare-files (system target) `(assert-equal (system-lisp-files ,system) (makefile-lisp-files ,target))) diff --git a/uiop/run-program.lisp b/uiop/run-program.lisp index f511b78c..7f34e185 100644 --- a/uiop/run-program.lisp +++ b/uiop/run-program.lisp @@ -761,7 +761,8 @@ It returns a process-info plist with possible keys: (reduce/strcat (append before (redirect in " <") (redirect out " >") (redirect err " 2>") - (when (and directory (os-unix-p)) `("cd " (escape-shell-token directory) " ; ")) + (when (and directory (os-unix-p)) + `(" ; cd " ,(escape-shell-token (native-namestring directory)))) after))))) (defun %system (command &rest keys diff --git a/uiop/stream.lisp b/uiop/stream.lisp index c4b0d29a..fcd31f95 100644 --- a/uiop/stream.lisp +++ b/uiop/stream.lisp @@ -535,14 +535,15 @@ If a string, repeatedly read and evaluate from it, returning the last values." (defun call-with-temporary-file (thunk &key (want-stream-p t) (want-pathname-p t) (direction :io) keep after - directory prefix suffix (type ".tmp") + directory (type "tmp" typep) prefix (suffix (when typep "-tmp")) (element-type *default-stream-element-type*) (external-format *utf-8-external-format*)) "Call a THUNK with stream and/or pathname arguments identifying a temporary file. The temporary file's pathname will be based on concatenating PREFIX (defaults to \"uiop\"), a random alphanumeric string, -and optional SUFFIX and TYPE (defaults to \".tmp\"), +and optional SUFFIX (defaults to \"-tmp\" if a type was provided) +and TYPE (defaults to \"tmp\", using a dot as separator if not NIL), within DIRECTORY (defaulting to the TEMPORARY-DIRECTORY) if the PREFIX isn't absolute. The file will be open with specified DIRECTION (defaults to :IO), -- GitLab