Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

useless use of cat

  • Loading branch information...
commit 55e1226f7da67b87413889e25547dc01069c0884 1 parent a33a411
rupa authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 z.sh
12 z.sh
View
@@ -40,9 +40,9 @@ _z() {
# maintain the file
local tempfile
tempfile="$(mktemp $datafile.XXXXXX)" || return
- cat "$datafile" | while read line; do
+ while read line; do
[ -d "${line%%\|*}" ] && echo $line
- done | awk -v path="$*" -v now="$(date +%s)" -F"|" '
+ done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
BEGIN {
rank[path] = 1
time[path] = now
@@ -71,9 +71,9 @@ _z() {
# tab completion
elif [ "$1" = "--complete" ]; then
- cat "$datafile" | while read line; do
+ while read line; do
[ -d "${line%%\|*}" ] && echo $line
- done | awk -v q="$2" -F"|" '
+ done < "$datafile" | awk -v q="$2" -F"|" '
BEGIN {
if( q == tolower(q) ) nocase = 1
split(substr(q,3),fnd," ")
@@ -110,9 +110,9 @@ _z() {
[ -f "$datafile" ] || return
local cd
- cd="$(cat "$datafile" | while read line; do
+ cd="$(while read line; do
[ -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) {
dx = t-time
if( dx < 3600 ) return rank*4
Please sign in to comment.
Something went wrong with that request. Please try again.