bash_completion: do not use aliased hg if it sources a script (issue6308) stable
authorPeter Arrenbrecht <peter@arrenbrecht.ch>
Mon, 11 May 2020 08:13:40 +0200
branchstable
changeset 44820 f71c8eea7161
parent 44819 a6e12d477595
child 44821 edffab2cf0ea
bash_completion: do not use aliased hg if it sources a script (issue6308) I have an alias that sources a script around hg. Mercurial's bash_completion script tries to use this as its main hg binary. But sourcing a wrapper breaks Bash's completion. So this patch disables using the alias as the hg binary if it starts with "source ". Alias resolution was introduced in rev 191ab08e7099 for users with "alias hg='hg --some_opts'". See https://www.mercurial-scm.org/repo/hg/rev/191ab08e7099
contrib/bash_completion
--- a/contrib/bash_completion	Tue May 12 01:03:12 2020 +0200
+++ b/contrib/bash_completion	Mon May 11 08:13:40 2020 +0200
@@ -160,7 +160,10 @@
     if [[ -n "$aliashg" ]]; then
       aliashg=${aliashg#"alias $hg='"}
       aliashg=${aliashg%"'"}
-      hg=$aliashg
+      # `source`d aliases break completion, so ignore them
+      if [[ "${aliashg:0:7}" != "source " ]]; then
+        hg=$aliashg
+      fi
     fi
 
     COMPREPLY=()