contrib/bash_completion
changeset 1805 2af98c4b2587
parent 1684 cf930b2452d3
child 1820 7e10518b2b9e
--- a/contrib/bash_completion	Sun Feb 26 16:23:14 2006 +0100
+++ b/contrib/bash_completion	Tue Feb 28 11:49:35 2006 -0600
@@ -3,23 +3,23 @@
 _hg_command_list()
 {
     "$hg" --debug help 2>/dev/null | \
-	awk 'function command_line(line) {
-		gsub(/,/, "", line)
-		gsub(/:.*/, "", line)
-		split(line, aliases)
-		command = aliases[1]
-		delete aliases[1]
+	awk -F', ' '/^list of commands:/ {commands=1}
+	    commands && /^ [^ ]/ {
+		sub(/ /, "")
+		sub(/:.*/, "")
+		command = $1
+		if (index(command, "debug") == 1) {
+		    for (i=1; i<=NF; i++)
+			debug[j++] = $i
+		    next
+		}
 		print command
-		for (i in aliases)
-		    if (index(command, aliases[i]) != 1)
-			print aliases[i]
+		for (i=2; i<=NF; i++)
+		    if (index(command, $i) != 1)
+			print $i
 	    }
-	    /^list of commands:/ {commands=1}
-	    commands && /^ debug/ {a[i++] = $0; next;}
-	    commands && /^ [^ ]/ {command_line($0)}
 	    /^global options:/ {exit 0}
-	    END {for (i in a) command_line(a[i])}'
-
+	    END {for (i in debug) print debug[i]}'
 }
 
 _hg_option_list()