From d37a763a6a30e1b32766fecc3b8ffd6127f8a0fd Mon Sep 17 00:00:00 2001 From: Jonathan Dahan Date: Sat, 9 Dec 2023 17:41:33 -0500 Subject: [PATCH] Escape calls for sed and awk in case someone aliased them (#264) Co-authored-by: Jonathan Dahan Co-authored-by: rupa --- z.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/z.sh b/z.sh index 8e66074..fec8d1c 100644 --- a/z.sh +++ b/z.sh @@ -70,7 +70,7 @@ _z() { # maintain the data file local tempfile="$datafile.$RANDOM" local score=${_Z_MAX_SCORE:-9000} - _z_dirs | awk -v path="$*" -v now="$(\date +%s)" -v score=$score -F"|" ' + _z_dirs | \awk -v path="$*" -v now="$(\date +%s)" -v score=$score -F"|" ' BEGIN { rank[path] = 1 time[path] = now @@ -103,7 +103,7 @@ _z() { # tab completion elif [ "$1" = "--complete" -a -s "$datafile" ]; then - _z_dirs | awk -v q="$2" -F"|" ' + _z_dirs | \awk -v q="$2" -F"|" ' BEGIN { q = substr(q, 3) if( q == tolower(q) ) imatch = 1 @@ -128,7 +128,7 @@ _z() { l) list=1;; r) typ="rank";; t) typ="recent";; - x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; + x) \sed -i -e "\:^${PWD}|.*:d" "$datafile";; esac; opt=${opt:1}; done;; *) fnd="$fnd${fnd:+ }$1";; esac; last=$1; [ "$#" -gt 0 ] && shift; done @@ -144,7 +144,7 @@ _z() { [ -f "$datafile" ] || return local cd - cd="$( < <( _z_dirs ) awk -v t="$(\date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' + cd="$( < <( _z_dirs ) \awk -v t="$(\date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' function frecent(rank, time) { # relate frequency and time dx = t - time