##// END OF EJS Templates
bash_completion: small optimization...
Alexis S. L. Carvalho -
r2039:0c438fd2 default
parent child Browse files
Show More
@@ -99,13 +99,38 b' shopt -s extglob'
99 return
99 return
100 fi
100 fi
101
101
102 # canonicalize command name
102 # try to generate completion candidates for whatever command the user typed
103 cmd=$("$hg" -q help "$cmd" 2>/dev/null | sed -e 's/^hg //; s/ .*//; 1q')
103 local help
104 local canonical=0
105 if _hg_command_specific; then
106 return
107 fi
104
108
105 if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then
109 # canonicalize the command name and try again
106 _hg_tags
110 help=$("$hg" help "$cmd" 2>/dev/null)
111 if [ $? -ne 0 ]; then
112 # Probably either the command doesn't exist or it's ambiguous
107 return
113 return
108 fi
114 fi
115 cmd=${help#hg }
116 cmd=${cmd%%[$' \n']*}
117 canonical=1
118 _hg_command_specific
119 }
120
121 _hg_command_specific()
122 {
123 if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then
124 if [ $canonical = 1 ]; then
125 _hg_tags
126 return 0
127 elif [[ status != "$cmd"* ]]; then
128 _hg_tags
129 return 0
130 else
131 return 1
132 fi
133 fi
109
134
110 case "$cmd" in
135 case "$cmd" in
111 help)
136 help)
@@ -152,8 +177,12 b' shopt -s extglob'
152 debugdata)
177 debugdata)
153 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
178 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
154 ;;
179 ;;
180 *)
181 return 1
182 ;;
155 esac
183 esac
156
184
185 return 0
157 }
186 }
158
187
159 complete -o bashdefault -o default -F _hg hg 2>/dev/null \
188 complete -o bashdefault -o default -F _hg hg 2>/dev/null \
General Comments 0
You need to be logged in to leave comments. Login now