# HG changeset patch # User Alexis S. L. Carvalho # Date 1141148975 21600 # Node ID 2af98c4b258713946046ec903cd77d36c7f2e205 # Parent c3f959c1c3fffd769485feb2d41b4a22062d440d 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). diff -r c3f959c1c3ff -r 2af98c4b2587 contrib/bash_completion --- 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()