Skip to content

Commit

Permalink
useless use of cat
Browse files Browse the repository at this point in the history
  • Loading branch information
rupa committed Jun 23, 2012
1 parent a33a411 commit 55e1226
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions z.sh
Expand Up @@ -40,9 +40,9 @@ _z() {
# maintain the file # maintain the file
local tempfile local tempfile
tempfile="$(mktemp $datafile.XXXXXX)" || return tempfile="$(mktemp $datafile.XXXXXX)" || return
cat "$datafile" | while read line; do while read line; do
[ -d "${line%%\|*}" ] && echo $line [ -d "${line%%\|*}" ] && echo $line
done | awk -v path="$*" -v now="$(date +%s)" -F"|" ' done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
BEGIN { BEGIN {
rank[path] = 1 rank[path] = 1
time[path] = now time[path] = now
Expand Down Expand Up @@ -71,9 +71,9 @@ _z() {


# tab completion # tab completion
elif [ "$1" = "--complete" ]; then elif [ "$1" = "--complete" ]; then
cat "$datafile" | while read line; do while read line; do
[ -d "${line%%\|*}" ] && echo $line [ -d "${line%%\|*}" ] && echo $line
done | awk -v q="$2" -F"|" ' done < "$datafile" | awk -v q="$2" -F"|" '
BEGIN { BEGIN {
if( q == tolower(q) ) nocase = 1 if( q == tolower(q) ) nocase = 1
split(substr(q,3),fnd," ") split(substr(q,3),fnd," ")
Expand Down Expand Up @@ -110,9 +110,9 @@ _z() {
[ -f "$datafile" ] || return [ -f "$datafile" ] || return


local cd local cd
cd="$(cat "$datafile" | while read line; do cd="$(while read line; do
[ -d "${line%%\|*}" ] && echo $line [ -d "${line%%\|*}" ] && echo $line
done | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) { function frecent(rank, time) {
dx = t-time dx = t-time
if( dx < 3600 ) return rank*4 if( dx < 3600 ) return rank*4
Expand Down

0 comments on commit 55e1226

Please sign in to comment.