From b04b38efa74d4461fc7890c572f3ffecf46af6f8 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 22 May 2026 11:07:30 -0700 Subject: [PATCH] diff: move temp file to $TMPDIR or /tmp Android uses a read-only source tree, and diff is run from the root of the source tree, leading to failures creating a temporary file in the current directory. --- toys/pending/diff.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toys/pending/diff.c b/toys/pending/diff.c index 00d0122f..21bf8dd3 100644 --- a/toys/pending/diff.c +++ b/toys/pending/diff.c @@ -348,10 +348,12 @@ static int *diff(char **files) for (i = 0; i < 2; i++) { if ((j = !strcmp(files[i], "-")) || S_ISFIFO(TT.st[i].st_mode)) { + char *tmp = xmprintf("%s/fifo", getenv("TMPDIR") ? : "/tmp"); char *tmp_name; int srcfd = j ? 0 : open(files[i], O_RDONLY), - tmpfd = xtempfile("fifo", &tmp_name); + tmpfd = xtempfile(tmp, &tmp_name); + free(tmp); unlink(tmp_name); free(tmp_name); -- 2.39.5