diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-10-12 20:52:54 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-10-12 20:52:54 +1300 |
commit | b43f3f7aafbede00ba9c63697a2db659f1d60e9c (patch) | |
tree | 3448303e47b161350746184ff83ff9be75b550bc /bash | |
parent | Inline unneeded variable in completion function (diff) | |
download | dotfiles-b43f3f7aafbede00ba9c63697a2db659f1d60e9c.tar.gz dotfiles-b43f3f7aafbede00ba9c63697a2db659f1d60e9c.zip |
Adjust declarations of local vars in compspecs
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/ftp.bash | 6 | ||||
-rw-r--r-- | bash/bashrc.d/mysql.bash | 2 | ||||
-rw-r--r-- | bash/bashrc.d/ssh.bash | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/bash/bashrc.d/ftp.bash b/bash/bashrc.d/ftp.bash index 8952cbb8..e46cc474 100644 --- a/bash/bashrc.d/ftp.bash +++ b/bash/bashrc.d/ftp.bash @@ -1,10 +1,9 @@ # Completion for ftp with .netrc machines _ftp() { - local netrc=$HOME/.netrc local word=${COMP_WORDS[COMP_CWORD]} - local -a machines # Bail if the .netrc file is illegible + local netrc=$HOME/.netrc if [[ ! -r $netrc ]]; then return 1 fi @@ -14,7 +13,8 @@ _ftp() { IFS=$' \t\n' read -a tokens -d '' -r < "$netrc" # Iterate through tokens and collect machine names - local machine=0 + local -a machines + local token machine for token in "${tokens[@]}"; do if ((machine)); then machines=("${machines[@]}" "$token") diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash index 45bdef8d..992d342c 100644 --- a/bash/bashrc.d/mysql.bash +++ b/bash/bashrc.d/mysql.bash @@ -20,6 +20,7 @@ mysql() { # Completion setup for MySQL for configured databases _mysql() { + local word=${COMP_WORDS[COMP_CWORD]} # Check directory exists and has at least one .cnf file local dir="$HOME"/.mysql @@ -33,7 +34,6 @@ _mysql() { fi # Return the names of the .cnf files sans prefix as completions - local word=${COMP_WORDS[COMP_CWORD]} local -a items items=("$dir"/*.cnf) items=("${items[@]##*/}") diff --git a/bash/bashrc.d/ssh.bash b/bash/bashrc.d/ssh.bash index c382bb17..6ce73d24 100644 --- a/bash/bashrc.d/ssh.bash +++ b/bash/bashrc.d/ssh.bash @@ -1,15 +1,15 @@ # Completion for ssh/sftp/ssh-copy-id with config hostnames _ssh() { - local config=$HOME/.ssh/config local word=${COMP_WORDS[COMP_CWORD]} - local -a hosts # Bail if the configuration file is illegible + local config=$HOME/.ssh/config if [[ ! -r $config ]]; then return 1 fi # Read hostnames from the file, no asterisks + local -a hosts local option value while read -r option value _; do if [[ $option == Host && $value != *'*'* ]]; then |