[Bash-completion-devel] Fixed competion of '~' and '~xx' in _filedir_xspec()

wonder.mice wonder.mice at gmail.com
Sun Aug 26 12:20:37 UTC 2012


As I understand, this patch solves "Please do not expand leading tildes" 
problem when _filedir_xspec is used (for vim, for example).

---

diff --git a/bash_completion b/bash_completion
index b58e37e..912a8e6 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1596,7 +1596,7 @@ _filedir_xspec()
      COMPREPLY=()
      _get_comp_words_by_ref cur

-    _expand || return 0
+    _tilde "$cur" || return 0

      # get first exclusion compspec that matches this command
      xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print 
\$0; exit }" \

On 08/25/2012 07:53 PM, wonder.mice wrote:
> Hello,
>
> I would like to fix issue with expanding '~' by several completion 
> scripts:
> #489720 [m|U☹|=↝] [bash-completion] bash-completion: Please do not 
> expand leading tildes
> #521406 [m|U☹|=↝] [bash-completion] bash-completion: leading tilde 
> always expanded
> please do not expand leading tildes 
> https://bugs.launchpad.net/bash-completion/+bug/324505
>
> As I understand, the problem is in _expand() function that is not 
> always correctly used.
> For example, in _filedir_xspec() it expands '~' regardless to bind 
> -v|grep expand-tilde option.
>
> This patch will not solve problems described above.
> I'm very new in bash and completion and I want to understand that I 
> got right direction.
>
> That patch fixes simple problem:
> $ vim ~mi<TAB>
> will not expand to
> $ vim ~mice/
>
> ----
>
> Use _tilde() to complete '~' and '~xx' like it done in _filedir().
>
> diff --git a/bash_completion b/bash_completion
> index f3488ba..beec07c 100644
> --- a/bash_completion
> +++ b/bash_completion
> @@ -1800,6 +1800,7 @@ _filedir_xspec()
> local cur prev words cword
> _init_completion || return
>
> + _tilde "$cur" || return 0
> _expand || return 0
>
> local IFS=$'\n' xspec=${_xspecs[${1##*/}]} tmp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bash_completion._filedir_sxpec-dont-expand-tilde.patch
Type: text/x-patch
Size: 417 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20120826/ec66dfdb/attachment.bin>


More information about the Bash-completion-devel mailing list