:if-output-exists support incomplete in run-program
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ASDF |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
(Putting this here so it's documented. Fixing it will be non-trivial)
run-program has an option :if-output-exists which defaults to :supersede. If run-program calls %run-program through %use-run-program (soon to be called launch-program and %use-launch-
If %system is used through %use-system instead, its value is discarded. Of the possible values :if-output-exists can take, :append is probably the one for which this is most surprising (you'll end up overwriting instead of appending to the file in question!). The fix would be to use '>>' instead of '>' here (this should work both in POSIX shell and CMD.EXE). If we also wanted to get things like :if-input-
Please note that CLISP essentially does not support launch-program so that this is not easily worked around portably.
Changed in asdf: | |
status: | New → Fix Committed |
Changed in asdf: | |
status: | Fix Committed → Fix Released |
I've thought a bit about this. One way to address this that came to mind would be to precede the actual call in %system by
(with-open-file (dummy output :direction-output :if-file-exists if-output-exists))
and to additionally turn '> output' into '>> output'.
This should do the right thing for
- :if-output-exists :error (because with-open-file will signal an error)
- :if-output-exists :supersede (with-open-file will discard the old file and leave an empty one that we'll then append to)
- :if-output-exists :append (with-open-file will signal an error if the file is missing; otherwise, it will append nothing on its own and we'll append to the existing file)
What I'm afraid this would handle properly I'm afraid is
- :if-output-exists nil
(which raises the question: which values of :if-output-exists do we support anyway? :overwrite is currently treated as :supersede e.g. because the error signalling of :overwrite does not work reliably in %run-program/ launch- program)