Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _git: Don't cause errors if git isn't installed



Setting up a new system under Cygwin on Windows 7, one of the first
things I tried (out of habit) was git<space><Tab>.  I'm not sure this is
the 'right' way to patch it, but other not-installed commands didn't
seem to cause the same kinds of errors:

$ screen <Tab># no extra output
$ php <Tab># no extra output
$ git <Tab>(eval):1: command not found: git
(eval):1: command not found: git

By "not the 'right' way", I just mean that this version accomplishes the goal
of eliminating the error messages, but maybe a more-correct solution would be
to replace some/all of the $(git...)-style calls with $(_call_program [tag]
git...)?

Best,
Ben
---
 Completion/Unix/Command/_git |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 465b316..b7eb681 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -30,6 +30,7 @@
 # zstyle ':completion::*:git-{name-rev,add,rm}:*' ignore-line true
 
 _git() {
+(( $+commands[git] )) || return 1
 local nul_arg abbrev_arg find_copies_harder_arg diff_l_arg pretty_arg exec_arg
 local author_conversion_file_arg long_author_conversion_file_arg verbose_arg
 local help_arg template_arg shared_arg thin_arg author_conversion_file_arg_spec
-- 
1.7.1



Messages sorted by: Reverse Date, Date, Thread, Author