Merge pull request #30 from Enlik/master

pull request: use actual return status; don't truncate file when disk full
This commit is contained in:
rupa committed 2011-06-29 13:07:21 -07:00
commit 979a33744a
1 file changed
+9 -4
+9 -4
View File
@@ -37,7 +37,8 @@ _z() {
[ "$*" = "$HOME" ] && return
# maintain the file
local tempfile="$(mktemp $datafile.XXXXXX)" || return
local tempfile
tempfile="$(mktemp $datafile.XXXXXX)" || return
awk -v path="$*" -v now="$(date +%s)" -F"|" '
BEGIN {
rank[path] = 1
@@ -59,7 +60,9 @@ _z() {
} else for( i in rank ) print i "|" rank[i] "|" time[i]
}
' "$datafile" 2>/dev/null >| "$tempfile"
env mv -f "$tempfile" "$datafile"
if [ $? -eq 0 ]; then
env mv -f "$tempfile" "$datafile"
fi
# tab completion
elif [ "$1" = "--complete" ]; then
@@ -98,8 +101,10 @@ _z() {
# no file yet
[ -f "$datafile" ] || return
local tempfile="$(mktemp $datafile.XXXXXX)" || return
local cd="$(awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -v tmpfl="$tempfile" -F"|" '
local tempfile
tempfile="$(mktemp $datafile.XXXXXX)" || return
local cd
cd="$(awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -v tmpfl="$tempfile" -F"|" '
function frecent(rank, time) {
dx = t-time
if( dx < 3600 ) return rank*4