git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] bash: remove unnecessary conditions when checking for subcommands

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Mar 10, 2008, 15:02 UTC
Message-ID
<1205161345-21120-1-git-send-email-szeder@ira.uka.de>
Checking emptyness of $command is sufficient.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 86b7ebe..39b2186 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -505,7 +505,7 @@ _git_bisect ()
 		c=$((++c))
 	done
 
-	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+	if [ -z "$command" ]; then
 		__gitcomp "start bad good reset visualize replay log"
 		return
 	fi
@@ -1050,7 +1050,7 @@ _git_remote ()
 		c=$((++c))
 	done
 
-	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+	if [ -z "$command" ]; then
 		__gitcomp "add rm show prune update"
 		return
 	fi
@@ -1143,7 +1143,7 @@ _git_submodule ()
 		c=$((++c))
 	done
 
-	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+	if [ -z "$command" ]; then
 		local cur="${COMP_WORDS[COMP_CWORD]}"
 		case "$cur" in
 		--*)
@@ -1206,7 +1206,7 @@ _git ()
 		c=$((++c))
 	done
 
-	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+	if [ -z "$command" ]; then
 		case "${COMP_WORDS[COMP_CWORD]}" in
 		--*=*) COMPREPLY=() ;;
 		--*)   __gitcomp "
-- 
1.5.4.4.481.g5075
Next: SZEDER Gábor
Message 1 of 5 in “bash: remove unnecessary conditions when checking for subcommands”
  1. 1/2 bash: remove unnecessary conditions when checking for subcommandsSZEDER Gábor, Mar 10, 2008
  2. 2/2 bash: refactor searching for subcommands on the command lineSZEDER Gábor, Mar 10, 2008
  3. bash: add new 'git stash' subcommandsSZEDER Gábor, Mar 10, 2008
  4. bash: add 'git svn' subcommands and optionsSZEDER Gábor, Mar 10, 2008
  5. Shawn O. PearceMar 10, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.