576e0992cac8a0cc4f824e20c0d60188578dd158

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

z: update to latest version (e77e938)

Closes #8145

Co-authored-by: GHPS <GHPS@users.noreply.github.com>

Diff

 1diff --git a/plugins/z/z.sh b/plugins/z/z.sh
 2index 5fe6d5266f8e124bfdf275bf8371e7586e049a57..5c5771d629d18af00487c53411592139494b70cf 100644
 3--- a/plugins/z/z.sh
 4+++ b/plugins/z/z.sh
 5@@ -89,7 +89,7 @@ _z() {
 6         if [ $? -ne 0 -a -f "$datafile" ]; then
 7             env rm -f "$tempfile"
 8         else
 9-            [ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile"
10+            [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
11             env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
12         fi
13 
14@@ -110,20 +110,21 @@ _z() {
15 
16     else
17         # list/go
18+        local echo fnd last list opt typ
19         while [ "$1" ]; do case "$1" in
20-            --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
21-            -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
22-                    c) local fnd="^$PWD $fnd";;
23-                    e) local echo=1;;
24+            --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
25+            -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
26+                    c) fnd="^$PWD $fnd";;
27+                    e) echo=1;;
28                     h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
29-                    l) local list=1;;
30-                    r) local typ="rank";;
31-                    t) local typ="recent";;
32+                    l) list=1;;
33+                    r) typ="rank";;
34+                    t) typ="recent";;
35                     x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
36                 esac; opt=${opt:1}; done;;
37-             *) local fnd="$fnd${fnd:+ }$1";;
38-        esac; local last=$1; [ "$#" -gt 0 ] && shift; done
39-        [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
40+             *) fnd="$fnd${fnd:+ }$1";;
41+        esac; last=$1; [ "$#" -gt 0 ] && shift; done
42+        [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
43 
44         # if we hit enter on a completion just go there
45         case "$last" in
46@@ -147,7 +148,7 @@ _z() {
47             function output(matches, best_match, common) {
48                 # list or return the desired directory
49                 if( list ) {
50-                    cmd = "sort -n >&2"
51+                    cmd = "sort -g >&2"
52                     for( x in matches ) {
53                         if( matches[x] ) {
54                             printf "%-10s %s\n", matches[x], x | cmd