From eacb0e8cd3805c8a37b721e9727696dbac2d3620 Mon Sep 17 00:00:00 2001 From: rupa Date: Thu, 2 Jul 2009 12:18:53 -0400 Subject: [PATCH] pass tmpfile name to awk in a variable. BSD awk (which OSX appears to use) doesn't like to redirect to concatenated filenames, and FILENAME is not available in the BEGIN clause, which is where i'd like to concatenate it, so this seemed the best approach. Closes gh-1 --- z.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/z.sh b/z.sh index 70b464c..81af1b5 100644 --- a/z.sh +++ b/z.sh @@ -64,7 +64,7 @@ z() { # if we hit enter on a completion just go there [ -d "$last" ] && cd "$last" && return [ -f "$datafile" ] || return - cd="$(awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' + cd="$(awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -v tmpfl="$datafile.tmp" -F"|" ' function frecent(rank, time) { dx = t-time if( dx < 3600 ) return rank*4 @@ -99,7 +99,7 @@ z() { BEGIN { split(q, a, " ") } { if( system("test -d \"" $1 "\"") ) next - print $0 >> FILENAME ".tmp" + print $0 >> tmpfl if( typ == "rank" ) { f = $2 } else if( typ == "recent" ) {