small pixel drawing of a pufferfish pa

use POSIX defined mkstemp in m4 instead of ad hoc mktemp
arĉi arcxi@dismail.de
Sun, 15 Sep 2024 15:00:04 +0200
commit

8f9a71fc3f65770e0c1e69506ddd432adfcac6d1

parent

0f43243c2c25df10a305910645d77b59ec4541da

1 files changed, 5 insertions(+), 11 deletions(-)

jump to
M papa

@@ -53,17 +53,10 @@ # and shared memory space on other operating systems

# have non-standard methods of setup/access. [ -w /dev/shm ] || tmpdir=/tmp - # Reimplement mktemp here, because - # mktemp isn't defined in POSIX. - suffix=$(rand_chars 10 'A-Za-z0-9') || - die "Couldn't generate random characters" - - tmpfile=$tmpdir/pa.$suffix/$name.age - - mkdir -p "$(dirname "$tmpfile")" || - die "Couldn't create a shared memory dir" + tmpfile=$(printf 'mkstemp(%s/pa.XXXXXX)' $tmpdir | m4) || + die "Couldn't create a shared memory file" - trap 'rm -rf "$tmpdir/pa.$suffix"' EXIT + trap 'rm -f "$tmpfile"' EXIT if [ ! -f "$name.age" ]; then new=true; else new=false && { $age --decrypt -i "$identities_file" -o "$tmpfile" "./$name.age" ||

@@ -72,9 +65,10 @@ }; fi

${EDITOR:-vi} "$tmpfile" - [ -f "$tmpfile" ] && { + [ -s "$tmpfile" ] && { mkdir -p "$(dirname "./$name")" || die "Couldn't create category '$(dirname "./$name" | cut -c3-)'" + $age --encrypt -R "$recipients_file" -o "./$name.age" "$tmpfile" || die "Couldn't encrypt $name.age"