mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 13:26:37 +00:00
Merge pull request #1592 from N-R-K/nmv_tmp_cleanup
nmv: ensure the tmpfile is cleaned up in all cases
This commit is contained in:
commit
a4745272db
|
@ -37,8 +37,6 @@ esac
|
|||
|
||||
exit_status=0
|
||||
|
||||
dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX")
|
||||
|
||||
if nnn_use_selection "Rename"; then
|
||||
# shellcheck disable=SC2154
|
||||
arr=$(tr '\0' '\n' < "$selection")
|
||||
|
@ -65,6 +63,9 @@ fi
|
|||
lines=$(printf "%s\n" "$arr" | wc -l)
|
||||
width=${#lines}
|
||||
|
||||
dst_file=$(mktemp "$TMPDIR/.nnnXXXXXX")
|
||||
trap 'rm -f "$dst_file"' EXIT
|
||||
|
||||
printf "%s" "$arr" | awk '{printf("%'"${width}"'d %s\n", NR, $0)}' > "$dst_file"
|
||||
|
||||
items=("~")
|
||||
|
@ -170,5 +171,4 @@ for item in "${items[@]}"; do
|
|||
$RM_UTIL "$item"
|
||||
done
|
||||
|
||||
rm "$dst_file"
|
||||
exit $exit_status
|
||||
|
|
Loading…
Reference in a new issue