]> git.phdru.name Git - git-scripts.git/blobdiff - ls-status-carefully
Create tmp dir in advance; set trap to remove it
[git-scripts.git] / ls-status-carefully
index eca5999e90a8d47ddec783756ea8810444803c16..cecdfa4ab079b759d469876b4d54a81271e25765 100755 (executable)
@@ -1,12 +1,13 @@
 #! /bin/sh
 
+LSTMP="$HOME"/tmp/ls-status-carefully.tmp
+export LSTMP
+trap 'exec rm -rf "$LSTMP"' 0 HUP INT QUIT TERM
+
 cd "`dirname \"$0\"`" && prog_dir="`pwd`" &&
-cd "$HOME"/tmp && rm -rf ls-status-carefully.tmp &&
+rm -rf "$LSTMP" && mkdir "$LSTMP" &&
 
-LSTMP="$HOME"/tmp/ls-status-carefully.tmp \
 "$prog_dir"/do-all \
    'test "$g" = "$d/.git" || continue;' \
    'rsync -aW --del --protocol=28 "$d" "$LSTMP" && cd "$LSTMP/$b" &&' \
-   'test -n "`git status --short`" && echo "$d"' &&
-
-cd "$HOME"/tmp && exec rm -rf ls-status-carefully.tmp
+   'test -n "`git status --short`" && echo "$d"'