aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-12 02:59:56 -0600
committerRob Landley <rob@landley.net>2012-11-12 02:59:56 -0600
commit6fa8404c5cad710205e2cdb0f96b92a9810cafab (patch)
tree2f177f5d4ca92e0701196419e67872f61e914a16
parent9a853484082744d83e3c85a361be748d46003cc9 (diff)
downloadtoybox-6fa8404c5cad710205e2cdb0f96b92a9810cafab.tar.gz
Yet another attempt to get the fiddly patch file creation logic right.
-rw-r--r--toys/posix/patch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/toys/posix/patch.c b/toys/posix/patch.c
index 5af07a14..40d7cbcf 100644
--- a/toys/posix/patch.c
+++ b/toys/posix/patch.c
@@ -387,7 +387,9 @@ void patch_main(void)
// If we've got a file to open, do so.
} else if (!(toys.optflags & FLAG_p) || i <= TT.prefix) {
// If the old file was null, we're creating a new one.
- if (!strcmp(oldname, "/dev/null") && !oldsum) {
+ if ((!strcmp(oldname, "/dev/null") || !oldsum)
+ && access(name, F_OK))
+ {
printf("creating %s\n", name);
s = strrchr(name, '/');
if (s) {