|
|
@@ -147,15 +147,15 @@ _z() {
|
|
|
function output(matches, best_match, common) {
|
|
|
# list or return the desired directory
|
|
|
if( list ) {
|
|
|
+ if( common ) {
|
|
|
+ printf "%-10s %s\n", "common:", common > "/dev/stderr"
|
|
|
+ }
|
|
|
cmd = "sort -n >&2"
|
|
|
for( x in matches ) {
|
|
|
if( matches[x] ) {
|
|
|
printf "%-10s %s\n", matches[x], x | cmd
|
|
|
}
|
|
|
}
|
|
|
- if( common ) {
|
|
|
- printf "%-10s %s\n", "common:", common > "/dev/stderr"
|
|
|
- }
|
|
|
} else {
|
|
|
if( common ) best_match = common
|
|
|
print best_match
|
|
|
@@ -199,15 +199,22 @@ _z() {
|
|
|
# prefer case sensitive
|
|
|
if( best_match ) {
|
|
|
output(matches, best_match, common(matches))
|
|
|
+ exit
|
|
|
} else if( ibest_match ) {
|
|
|
output(imatches, ibest_match, common(imatches))
|
|
|
+ exit
|
|
|
}
|
|
|
+ exit(1)
|
|
|
}
|
|
|
')"
|
|
|
|
|
|
- [ $? -eq 0 ] && [ "$cd" ] && {
|
|
|
- if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
|
|
|
- }
|
|
|
+ if [ "$?" -eq 0 ]; then
|
|
|
+ if [ "$cd" ]; then
|
|
|
+ if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
|
|
|
+ fi
|
|
|
+ else
|
|
|
+ return $?
|
|
|
+ fi
|
|
|
fi
|
|
|
}
|
|
|
|