git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] git-completion.bash: remove bashism to fix ZSH compatibility
@ 2013-03-11 12:21 Matthieu Moy
  2013-03-11 16:17 ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Matthieu Moy @ 2013-03-11 12:21 UTC (permalink / raw)
  To: git; +Cc: Matthieu Moy

The function-wide redirection used for __git_ls_files_helper and
__git_diff_index_helper work only with bash. Using ZSH, trying to
complete an inexistant directory gave this:

  git add no-such-dir/__git_ls_files_helper:cd:2: no such file or directory: no-such-dir/

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
These two instances seem to be the only ones in the file.

I'm not sure whether the 2>/dev/null would be needed for the command
on the RHS of the && too (git ls-files and git diff-index).

 contrib/completion/git-completion.bash | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index b62bec0..0640274 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -300,8 +300,8 @@ __git_index_file_list_filter ()
 __git_ls_files_helper ()
 {
 	# NOTE: $2 is not quoted in order to support multiple options
-	cd "$1" && git ls-files --exclude-standard $2
-} 2>/dev/null
+	cd "$1" 2>/dev/null && git ls-files --exclude-standard $2
+}
 
 
 # Execute git diff-index, returning paths relative to the directory
@@ -309,8 +309,8 @@ __git_ls_files_helper ()
 # specified in the second argument.
 __git_diff_index_helper ()
 {
-	cd "$1" && git diff-index --name-only --relative "$2"
-} 2>/dev/null
+	cd "$1" 2>/dev/null && git diff-index --name-only --relative "$2"
+}
 
 # __git_index_files accepts 1 or 2 arguments:
 # 1: Options to pass to ls-files (required).
-- 
1.8.2.rc3.16.g0a33571.dirty

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-03-11 19:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 12:21 [RFC/PATCH] git-completion.bash: remove bashism to fix ZSH compatibility Matthieu Moy
2013-03-11 16:17 ` Junio C Hamano
2013-03-11 16:41   ` Junio C Hamano
2013-03-11 16:47     ` Matthieu Moy
2013-03-11 17:01       ` Junio C Hamano
2013-03-11 17:12         ` Manlio Perillo
2013-03-11 17:09   ` Manlio Perillo
2013-03-11 17:23     ` Junio C Hamano
2013-03-11 17:48       ` Matthieu Moy
2013-03-11 18:09         ` Junio C Hamano
2013-03-11 18:19           ` Paul Smith
2013-03-11 19:09           ` Manlio Perillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).