small pixel drawing of a pufferfish pa

Add nested item support to pw_edit()
Jes Olson jolson@digitalocean.com
Tue, 14 Dec 2021 12:04:47 -0600
commit

4c11b304e884dcbc70c07dfe9e7af243e3dbf1cc

parent

3e35c092c2abf05409ffe99a3a4912666541dc1d

1 files changed, 7 insertions(+), 4 deletions(-)

jump to
M papa

@@ -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"