aports/testing/doasedit/posix-2.patch

36 lines
1.2 KiB
Diff

Patch-Source: https://codeberg.org/TotallyLeGIT/doasedit/commit/0e1364877193727238db8a42c18894b3c087c3ba
--
From 0e1364877193727238db8a42c18894b3c087c3ba Mon Sep 17 00:00:00 2001
From: TotallyLeGIT <>
Date: Thu, 4 May 2023 15:05:32 +0200
Subject: [PATCH] Replace some mktemp with POSIX commands
While keeping functionality, this commit should increase portability by
replacing some `mktemp` commands with POSIX alternatives. The main
working directory is still created via `mktemp` though.
Fixes #7
---
CHANGELOG.md | 2 +-
doasedit | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/doasedit b/doasedit
index 4d5cc6f..7aa97ae 100755
--- a/doasedit
+++ b/doasedit
@@ -114,9 +114,11 @@ tmpdir="$(mktemp -dt 'doasedit-XXXXXX')"
for file; do
unset exists readable writable
- tmpfile="$(mktemp "${tmpdir}/XXXX-${file##*/}")"
- tmpfile_copy="$(mktemp "${tmpdir}/XXXX-copy-of-${file##*/}")"
dir="$(dirname -- "${file}")"
+ tmpfile="${tmpdir}/${file##*/}"
+ tmpfile_copy="${tmpdir}/copy-of-${file##*/}"
+ printf '' | tee "${tmpfile}" > "${tmpfile_copy}"
+ chmod 0600 "${tmpfile}" "${tmpfile_copy}"
if [ -e "${file}" ]; then
if ! [ -f "${file}" ]; then