Handle errors when aws_zsh_completer.sh not found

- Redirect `which` stderr output to /dev/null
- Check for empty `_aws_zsh_completer_path` variable
This commit is contained in:
Gordon Schulz 2016-07-01 09:18:35 +02:00
parent 7fabc8bca4
commit eaa320a8c5

View File

@ -30,8 +30,8 @@ compctl -K aws_profiles asp
if _homebrew-installed && _awscli-homebrew-installed ; then
_aws_zsh_completer_path=$(brew --prefix awscli)/libexec/bin/aws_zsh_completer.sh
else
_aws_zsh_completer_path=$(which aws_zsh_completer.sh)
_aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null)
fi
[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path