From 2fb7245c06168975d8f4410260a9140ae6c4ec84 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Fri, 3 Nov 2023 14:57:48 -0700 Subject: [PATCH] create leading directories if they don't exist This works for files without directories too because `dirname` prints `.` in that case. --- pkgs/agenix.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/agenix.sh b/pkgs/agenix.sh index 27a53c9..5e001fa 100644 --- a/pkgs/agenix.sh +++ b/pkgs/agenix.sh @@ -181,6 +181,8 @@ function edit { @ageBin@ "${ENCRYPT[@]}" <"$CLEARTEXT_FILE" || exit 1 + mkdir -p "$(dirname $FILE)" + mv -f "$REENCRYPTED_FILE" "$FILE" }