Commit c01c86f5 authored by Elias Pipping's avatar Elias Pipping

Change :if-*-exists default to :supersede

The difference between :overwrite (the former default) and :supersede
is only that the latter should not lead to an error if the file does
not exist. There is plenty of support for :supersede behaviour (not
necessarily under that name) but not for :overwrite behaviour. Hence
we make it the default and add a normaliser.

Since normalisation is currently only necessary for CLISP and CLISP
only has :if-output-exists support (not :if-error-output-exists or
:if-input-does-not-exist), we only translate :if-output-exists for now.
parent 9198e77f
...@@ -398,6 +398,11 @@ argument to pass to the internal RUN-PROGRAM" ...@@ -398,6 +398,11 @@ argument to pass to the internal RUN-PROGRAM"
:output :output
(error "Wrong specifier ~S for role ~S" specifier role))))) (error "Wrong specifier ~S for role ~S" specifier role)))))
(defun %normalize-if-exists (action)
(ecase action
(:supersede #+clisp :overwrite #-clisp action)
((:append :error) action)))
(defun %interactivep (input output error-output) (defun %interactivep (input output error-output)
(member :interactive (list input output error-output))) (member :interactive (list input output error-output)))
...@@ -419,8 +424,8 @@ argument to pass to the internal RUN-PROGRAM" ...@@ -419,8 +424,8 @@ argument to pass to the internal RUN-PROGRAM"
(defun %run-program (command (defun %run-program (command
&rest keys &rest keys
&key input (if-input-does-not-exist :error) &key input (if-input-does-not-exist :error)
output (if-output-exists :overwrite) output (if-output-exists :supersede)
error-output (if-error-output-exists :overwrite) error-output (if-error-output-exists :supersede)
directory wait directory wait
#+allegro separate-streams #+allegro separate-streams
&allow-other-keys) &allow-other-keys)
...@@ -438,6 +443,7 @@ It returns a process-info object." ...@@ -438,6 +443,7 @@ It returns a process-info object."
(error "run-program not available")) (error "run-program not available"))
#+(or allegro clasp clisp clozure cmucl ecl (and lispworks os-unix) mkcl sbcl scl) #+(or allegro clasp clisp clozure cmucl ecl (and lispworks os-unix) mkcl sbcl scl)
(let* ((%command (%normalize-command command)) (let* ((%command (%normalize-command command))
(%if-output-exists (%normalize-if-exists if-output-exists))
(%input (%normalize-io-specifier input :input)) (%input (%normalize-io-specifier input :input))
(%output (%normalize-io-specifier output :output)) (%output (%normalize-io-specifier output :output))
(%error-output (%normalize-io-specifier error-output :error-output)) (%error-output (%normalize-io-specifier error-output :error-output))
...@@ -474,9 +480,10 @@ It returns a process-info object." ...@@ -474,9 +480,10 @@ It returns a process-info object."
#-clisp `(#+(or allegro lispworks) :error-output #-(or allegro lispworks) :error #-clisp `(#+(or allegro lispworks) :error-output #-(or allegro lispworks) :error
,%error-output) ,%error-output)
#+(and allegro os-windows) `(:show-window ,(if interactive nil :hide)) #+(and allegro os-windows) `(:show-window ,(if interactive nil :hide))
#+clisp `(:if-output-exists ,%if-output-exists)
#+(or allegro clozure cmucl ecl lispworks mkcl sbcl scl) #+(or allegro clozure cmucl ecl lispworks mkcl sbcl scl)
`(:if-input-does-not-exist ,if-input-does-not-exist `(:if-input-does-not-exist ,if-input-does-not-exist
:if-output-exists ,if-output-exists :if-output-exists ,%if-output-exists
#-(or allegro lispworks) :if-error-exists #-(or allegro lispworks) :if-error-exists
#+(or allegro lispworks) :if-error-output-exists #+(or allegro lispworks) :if-error-output-exists
,if-error-output-exists) ,if-error-output-exists)
...@@ -861,8 +868,8 @@ It returns a process-info object." ...@@ -861,8 +868,8 @@ It returns a process-info object."
(defun run-program (command &rest keys (defun run-program (command &rest keys
&key ignore-error-status (force-shell nil force-shell-suppliedp) &key ignore-error-status (force-shell nil force-shell-suppliedp)
(input nil inputp) (if-input-does-not-exist :error) (input nil inputp) (if-input-does-not-exist :error)
output (if-output-exists :overwrite) output (if-output-exists :supersede)
(error-output nil error-output-p) (if-error-output-exists :overwrite) (error-output nil error-output-p) (if-error-output-exists :supersede)
(element-type #-clozure *default-stream-element-type* #+clozure 'character) (element-type #-clozure *default-stream-element-type* #+clozure 'character)
(external-format *utf-8-external-format*) (external-format *utf-8-external-format*)
&allow-other-keys) &allow-other-keys)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment