comparison contrib/bash_completion @ 1805:2af98c4b2587

Fix bash_completion on Solaris TK Soh noticed that the awk that ships with Solaris doesn't allow you to define new functions. According to http://www.shelldorado.com/articles/awkcompat.html it looks like it also doesn't have some other stuff that we were using, like deletion of an array element and gsub. Rewrite the parsing of hg --debug help to work around that. This version doesn't filter aliases that are simple abbreviations for debug commands (not a big problem, since there are none right now).
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 28 Feb 2006 11:49:35 -0600
parents cf930b2452d3
children 7e10518b2b9e
comparison
equal deleted inserted replaced
1804:c3f959c1c3ff 1805:2af98c4b2587
1 shopt -s extglob 1 shopt -s extglob
2 2
3 _hg_command_list() 3 _hg_command_list()
4 { 4 {
5 "$hg" --debug help 2>/dev/null | \ 5 "$hg" --debug help 2>/dev/null | \
6 awk 'function command_line(line) { 6 awk -F', ' '/^list of commands:/ {commands=1}
7 gsub(/,/, "", line) 7 commands && /^ [^ ]/ {
8 gsub(/:.*/, "", line) 8 sub(/ /, "")
9 split(line, aliases) 9 sub(/:.*/, "")
10 command = aliases[1] 10 command = $1
11 delete aliases[1] 11 if (index(command, "debug") == 1) {
12 for (i=1; i<=NF; i++)
13 debug[j++] = $i
14 next
15 }
12 print command 16 print command
13 for (i in aliases) 17 for (i=2; i<=NF; i++)
14 if (index(command, aliases[i]) != 1) 18 if (index(command, $i) != 1)
15 print aliases[i] 19 print $i
16 } 20 }
17 /^list of commands:/ {commands=1}
18 commands && /^ debug/ {a[i++] = $0; next;}
19 commands && /^ [^ ]/ {command_line($0)}
20 /^global options:/ {exit 0} 21 /^global options:/ {exit 0}
21 END {for (i in a) command_line(a[i])}' 22 END {for (i in debug) print debug[i]}'
22
23 } 23 }
24 24
25 _hg_option_list() 25 _hg_option_list()
26 { 26 {
27 "$hg" -v help $1 2>/dev/null | \ 27 "$hg" -v help $1 2>/dev/null | \