diff --git a/update-initramfs b/update-initramfs index 4bb8d8a..5fe7921 100755
--- a/update-initramfs +++ b/update-initramfs @@ -138,15 +138,16 @@ generate_initramfs() if [ "${verbose}" = 1 ]; then OPTS="-v ${OPTS}" fi + initramfs_tmp=$(mktemp) # shellcheck disable=SC2086 - if mkinitramfs ${OPTS} "${initramfs}.new" "${version}"; then - mv -f "${initramfs}.new" "${initramfs}" + if mkinitramfs ${OPTS} "${initramfs_tmp}" "${version}"; then + mv -f "${initramfs_tmp}" "${initramfs}" # Guard against an unclean shutdown sync -f "${initramfs}" else mkinitramfs_return="$?" remove_initramfs_bak - rm -f "${initramfs}.new" + rm -f "${initramfs_tmp}" echo "update-initramfs: failed for ${initramfs} with $mkinitramfs_return." >&2 exit $mkinitramfs_return fi -- 2.25.1