From db827eec154212ca828d267d25a64984ad8358ac Mon Sep 17 00:00:00 2001 From: rupa Date: Mon, 20 May 2013 12:51:43 -0400 Subject: [PATCH 1/2] Throw away tmp files if mv fails Attempt to get rid of stale temp files that occasionally drop. While there is anecdotal evidence that this doesn't solve the problem, it doesn't hurt, and it's the only place I can see to fix it. --- z.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/z.sh b/z.sh index 20539c5..7fc79ec 100644 --- a/z.sh +++ b/z.sh @@ -80,7 +80,7 @@ _z() { if [ $? -ne 0 -a -f "$datafile" ]; then env rm -f "$tempfile" else - env mv -f "$tempfile" "$datafile" + env mv -f "$tempfile" "$datafile" || env rm -f "$tmpfile" fi # tab completion From 8aac576b7cfcc2ac4fbad7e298bcacc29a03b731 Mon Sep 17 00:00:00 2001 From: rupa Date: Mon, 20 May 2013 20:50:19 -0400 Subject: [PATCH 2/2] revert warning if z.sh is being exec'd and not sourced Because we can't reliably determine if we're really being exec'd. --- z.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/z.sh b/z.sh index 7fc79ec..883ed3d 100644 --- a/z.sh +++ b/z.sh @@ -22,11 +22,6 @@ # * z -l foo # list matches instead of cd # * z -c foo # restrict matches to subdirs of $PWD -case $- in - *i*) ;; - *) echo 'ERROR: z.sh is meant to be sourced, not directly executed.' -esac - [ -d "${_Z_DATA:-$HOME/.z}" ] && { echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory." }