Update local variable definitions

This commit is contained in:
Lazarus Lazaridis 2018-03-08 03:45:58 +02:00
parent 92bd6ef882
commit e536db0aca

View File

@ -164,7 +164,7 @@ function _goto_unregister_alias
# Unregisters aliases whose directories no longer exist. # Unregisters aliases whose directories no longer exist.
function _goto_cleanup() function _goto_cleanup()
{ {
local match al dir local match matches al dir
mapfile -t matches < <(cat ~/.goto 2>/dev/null) mapfile -t matches < <(cat ~/.goto 2>/dev/null)
@ -185,6 +185,7 @@ function _goto_cleanup()
function _goto_directory() function _goto_directory()
{ {
local target local target
target=$(_goto_resolve_alias "$1") target=$(_goto_resolve_alias "$1")
if [ -n "$target" ]; then if [ -n "$target" ]; then
@ -214,6 +215,7 @@ function _goto_resolve_alias()
local resolved local resolved
resolved=$(_goto_find_alias_directory "$1") resolved=$(_goto_find_alias_directory "$1")
if [ -z "$resolved" ]; then if [ -z "$resolved" ]; then
_goto_error "unregistered alias $1" _goto_error "unregistered alias $1"
echo "" echo ""
@ -231,7 +233,7 @@ function _complete_goto_commands()
# Completes the goto function with the available aliases # Completes the goto function with the available aliases
function _complete_goto_aliases() function _complete_goto_aliases()
{ {
local IFS=$'\n' matches local IFS=$'\n' matches al
mapfile -t matches < <(sed -n "/^$1/p" ~/.goto 2>/dev/null) mapfile -t matches < <(sed -n "/^$1/p" ~/.goto 2>/dev/null)
@ -262,7 +264,7 @@ function _complete_goto_aliases()
# Bash programmable completion for the goto function # Bash programmable completion for the goto function
function _complete_goto() function _complete_goto()
{ {
local cur="${COMP_WORDS[$COMP_CWORD]}" local cur="${COMP_WORDS[$COMP_CWORD]}" prev
if [ "$COMP_CWORD" -eq "1" ]; then if [ "$COMP_CWORD" -eq "1" ]; then
# if we are on the first argument # if we are on the first argument
@ -275,7 +277,7 @@ function _complete_goto()
fi fi
elif [ "$COMP_CWORD" -eq "2" ]; then elif [ "$COMP_CWORD" -eq "2" ]; then
# if we are on the second argument # if we are on the second argument
local prev="${COMP_WORDS[1]}" prev="${COMP_WORDS[1]}"
if [[ $prev = "-u" ]] || [[ $prev = "--unregister" ]]; then if [[ $prev = "-u" ]] || [[ $prev = "--unregister" ]]; then
# prompt with aliases only if user tries to unregister one # prompt with aliases only if user tries to unregister one
@ -283,7 +285,7 @@ function _complete_goto()
fi fi
elif [ "$COMP_CWORD" -eq "3" ]; then elif [ "$COMP_CWORD" -eq "3" ]; then
# if we are on the third argument # if we are on the third argument
local prev="${COMP_WORDS[1]}" prev="${COMP_WORDS[1]}"
if [[ $prev = "-r" ]] || [[ $prev = "--register" ]]; then if [[ $prev = "-r" ]] || [[ $prev = "--register" ]]; then
# prompt with directories only if user tries to register an alias # prompt with directories only if user tries to register an alias