Skip to content

Commit 9d5a3fe

Browse files
author
rupa
committed
declare some local vars unconditionally
So they don't pick up if e.g. tmux defines $echo
1 parent ad437e8 commit 9d5a3fe

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

z.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,21 @@ _z() {
110110

111111
else
112112
# list/go
113+
local echo fnd last list opt typ
113114
while [ "$1" ]; do case "$1" in
114-
--) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
115-
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
116-
c) local fnd="^$PWD $fnd";;
117-
e) local echo=1;;
115+
--) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
116+
-*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
117+
c) fnd="^$PWD $fnd";;
118+
e) echo=1;;
118119
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
119-
l) local list=1;;
120-
r) local typ="rank";;
121-
t) local typ="recent";;
120+
l) list=1;;
121+
r) typ="rank";;
122+
t) typ="recent";;
122123
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
123124
esac; opt=${opt:1}; done;;
124-
*) local fnd="$fnd${fnd:+ }$1";;
125-
esac; local last=$1; [ "$#" -gt 0 ] && shift; done
126-
[ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
125+
*) fnd="$fnd${fnd:+ }$1";;
126+
esac; last=$1; [ "$#" -gt 0 ] && shift; done
127+
[ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
127128

128129
# if we hit enter on a completion just go there
129130
case "$last" in

0 commit comments

Comments
 (0)