Skip to content

Commit

Permalink
declare some local vars unconditionally
Browse files Browse the repository at this point in the history
So they don't pick up if e.g. tmux defines $echo
  • Loading branch information
rupa committed Aug 10, 2018
1 parent ad437e8 commit 9d5a3fe
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,21 @@ _z() {

else
# list/go
local echo fnd last list opt typ
while [ "$1" ]; do case "$1" in
--) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
c) local fnd="^$PWD $fnd";;
e) local echo=1;;
--) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
-*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
c) fnd="^$PWD $fnd";;
e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
l) local list=1;;
r) local typ="rank";;
t) local typ="recent";;
l) list=1;;
r) typ="rank";;
t) typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;;
*) local fnd="$fnd${fnd:+ }$1";;
esac; local last=$1; [ "$#" -gt 0 ] && shift; done
[ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
*) fnd="$fnd${fnd:+ }$1";;
esac; last=$1; [ "$#" -gt 0 ] && shift; done
[ "$fnd" -a "$fnd" != "^$PWD " ] || list=1

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

0 comments on commit 9d5a3fe

Please sign in to comment.