Skip to content

Commit

Permalink
Escape calls for sed and awk in case someone aliased them (#264)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonathan Dahan <hi@jonathan.is>
Co-authored-by: rupa <rupa@lrrr.us>
  • Loading branch information
3 people committed Dec 9, 2023
1 parent 703bb54 commit d37a763
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions z.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d37a763

Please sign in to comment.