# pa: pw_edit()
# prefer /dev/shm because its an in-memory
# space that we can use to store data without
# having bits laying around in sectors.
tmpdir=/dev/shm
# fall back to /tmp - /dev/shm is Linux-only & /tmp
# 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 isnt defined in POSIX.
tmpfile=${tmpdir}/pa.$(rand_chars 10 'A-Za-z0-9') ||
    die "couldn't generate random characters"

trap 'rm -f "$tmpfile"' EXIT

die() {
  printf '%s: %s.\n' "$(basename "$0")" "$1" >&2
  exit 1
}
