From 05591973d7a546f84c60f4992715f8a5e3d74378 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Fri, 3 Nov 2023 14:53:33 -0700 Subject: [PATCH 1/2] use named variable instead of numbered one --- pkgs/agenix.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/agenix.sh b/pkgs/agenix.sh index f638b10..27a53c9 100644 --- a/pkgs/agenix.sh +++ b/pkgs/agenix.sh @@ -181,7 +181,7 @@ function edit { @ageBin@ "${ENCRYPT[@]}" <"$CLEARTEXT_FILE" || exit 1 - mv -f "$REENCRYPTED_FILE" "$1" + mv -f "$REENCRYPTED_FILE" "$FILE" } function rekey { From 65fe5959c3014be90cbc046f30288b6e14beff48 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Fri, 3 Nov 2023 14:57:48 -0700 Subject: [PATCH 2/2] 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..5212977 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" }