[PATCH 4 of 8 V2] bash_completion: determine root executable in case of alias
Sean Farley
sean.michael.farley at gmail.com
Fri Nov 22 14:26:04 CST 2013
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1384971595 18000
# Wed Nov 20 13:19:55 2013 -0500
# Node ID f61f023f810471446058ff05db4bf255560f4a90
# Parent d74d30e3165e68bbd0c27290c8e8211e2dadd4ed
bash_completion: determine root executable in case of alias
This solves an issue for users that have "alias hg='hg --some_opts'" where they
would see wrong entries in the completion output (such as color codes).
diff --git a/contrib/bash_completion b/contrib/bash_completion
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -128,16 +128,23 @@
echo $(($count - 1))
}
_hg()
{
- local cur prev cmd cmd_index opts i
+ local cur prev cmd cmd_index opts i aliashg
# global options that receive an argument
local global_args='--cwd|-R|--repository'
local hg="$1"
local canonical=0
+ aliashg=$(alias $hg 2>/dev/null)
+ if [[ -n "$aliashg" ]]; then
+ aliashg=${aliashg#"alias $hg='"}
+ aliashg=${aliashg%"'"}
+ hg=$aliashg
+ fi
+
COMPREPLY=()
cur="$2"
prev="$3"
# searching for the command
More information about the Mercurial-devel
mailing list