From bf523cdc679938692935cedd951f4863d66d3af0 Mon Sep 17 00:00:00 2001 From: Danny Nemer Date: Wed, 26 Aug 2015 20:43:54 -0400 Subject: [PATCH] Partially fix '-x' argument Previously, on OS X, the command `sed -i -e` was used incorrectly and made a backup file named ".ze". Using `sed -i ''` prevents this backup file from being created (on OS X). Previously, after running `z -x`, the datafile would be printed as if `z` failed to find results for a query. But, because `z -x` would never be used with args (i.e., a query), it is best to `return` like the `-h` command. However, the `z -x` still does not work because of `precmd`, which adds the current directory to the datafile after every `z` run regardless of the arguments. `z -x` correctly modifies the datafile, but after, `z` add the current directory back. --- z.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/z.sh b/z.sh index 713b452..e7c4117 100644 --- a/z.sh +++ b/z.sh @@ -107,7 +107,7 @@ _z() { -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in c) local fnd="^$PWD $fnd";; h) echo "${_Z_CMD:-z} [-chlrtx] args" >&2; return;; - x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; + x) sed -i '' "\:^${PWD}|.*:d" "$datafile"; return;; l) local list=1;; r) local typ="rank";; t) local typ="recent";;