Add nested item support to pw_edit()
Jes Olson jolson@digitalocean.com
Tue, 14 Dec 2021 12:04:47 -0600
1 files changed,
7 insertions(+),
4 deletions(-)
jump to
M
pa
→
pa
@@ -60,12 +60,15 @@ # and securely wipe it without worrying about
# residual badness [ -d /dev/shm ] || die "Failed to access /dev/shm" - mkdir -p /dev/shm/pa + # get base dirname in case we're dealing with + # a nested item (foo/bar) + tmpfile="/dev/shm/pa/$name.txt" + tmpdir="$(dirname $tmpfile)" + mkdir -p "$tmpdir" trap 'rm -rf /dev/shm/pa' EXIT - tmpfile="/dev/shm/pa/$name.txt" - age -i ~/.age/key.txt --decrypt "$1.age" 2>/dev/null > "$tmpfile" || - die "Could not decrypt $1.age" + age -i ~/.age/key.txt --decrypt "$name.age" 2>/dev/null > "$tmpfile" || + die "Could not decrypt $name.age" "${EDITOR:-vi}" "$tmpfile"