apenwarr-redo/redo
Avery Pennarun d95277d121 Use mkstemp() to create the stdout temp file, and simplify $3 path.
Previously, we'd try to put the stdout temp file in the same dir as the
target, if that dir exists.  Otherwise we'd walk up the directory tree
looking for a good place.  But this would go wrong if the directory we
chose got *deleted* during the run of the .do file.

Instead, we switch to an entirely new design: we use mkstemp() to
generate a temp file in the standard temp file location (probably
/tmp), then open it and immediately delete it, so the .do file can't
cause any unexpected behaviour.  After the .do file exits, we use our
still-open fd to the stdout file to read the content back out.

In the old implementation, we also put the $3 in the "adjusted"
location that depended whether the target dir already existed, just for
consistency.  But that was never necessary: we didn't create the $3
file, and if the .do script wants to write to $3, it should create the
target dir first anyway.  So change it to *always* use a $3 temp
filename in the target dir, which is much simpler and so has fewer edge
cases.

Add t/202-del/deltest4 with some tests for all these edge cases.

Reported-by: Jeff Stearns <jeff.stearns@gmail.com>
2018-12-13 13:28:44 +00:00
..
version Switch to module-relative import syntax. 2018-12-05 02:34:36 -05:00
.gitignore Rename redo/python -> redo/py. 2018-12-05 02:27:04 -05:00
__init__.py Directory reorg: move code into redo/, generate binaries in bin/. 2018-12-04 02:53:40 -05:00
atoi.py Directory reorg: move code into redo/, generate binaries in bin/. 2018-12-04 02:53:40 -05:00
builder.py Use mkstemp() to create the stdout temp file, and simplify $3 path. 2018-12-13 13:28:44 +00:00
clean.do Rename redo/python -> redo/py. 2018-12-05 02:27:04 -05:00
cmd_always.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_ifchange.py Some renaming and comments to try to clarify builder and jobserver. 2018-12-11 04:17:27 +00:00
cmd_ifcreate.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_log.py Switch to module-relative import syntax. 2018-12-05 02:34:36 -05:00
cmd_ood.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_redo.py Some renaming and comments to try to clarify builder and jobserver. 2018-12-11 04:17:27 +00:00
cmd_sources.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_stamp.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_targets.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_unlocked.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cmd_whichdo.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
cycles.py Move env.{add,get}_lock() into cycles.py, and rename. 2018-12-05 02:26:58 -05:00
deps.py Switch to module-relative import syntax. 2018-12-05 02:34:36 -05:00
env.py Switch to module-relative import syntax. 2018-12-05 02:34:36 -05:00
helpers.py Directory reorg: move code into redo/, generate binaries in bin/. 2018-12-04 02:53:40 -05:00
jobserver.py Some renaming and comments to try to clarify builder and jobserver. 2018-12-11 04:17:27 +00:00
logs.py Make calls to logs.setup() explicit in each cmd. 2018-12-11 02:35:11 +00:00
options.py Directory reorg: move code into redo/, generate binaries in bin/. 2018-12-04 02:53:40 -05:00
paths.py Switch to module-relative import syntax. 2018-12-05 02:34:36 -05:00
py.do Rename redo/python -> redo/py. 2018-12-05 02:27:04 -05:00
sh.do Fix minimal/do and tests when built in a path containing spaces. 2018-12-11 01:22:29 +00:00
state.py Switch to module-relative import syntax. 2018-12-05 02:34:36 -05:00
title.py Move setproctitle() stuff into title.py. 2018-12-05 02:28:34 -05:00
whichpython.do Directory reorg: move code into redo/, generate binaries in bin/. 2018-12-04 02:53:40 -05:00