[Bash-completion-devel] [PATCH] Check _rl_enabled expand-tilde before calling _expand

wonder.mice wonder.mice at gmail.com
Wed Aug 22 21:25:18 UTC 2012


This patch will check

    _rl_enabled expand-tilde

before calling _expand.

This will fix issues like that:
#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

Also this patch will not break scp and others, like described here:
http://lists.alioth.debian.org/pipermail/bash-completion-devel/2009-February/000973.html

The same change (replace "_expand || return 0" with "_rl_enabled 
expand-tilde && (_expand || return 0)") also must be done in following 
files in /etc/bash_completion.d:

    bash$ grep -rn " _expand" /etc/bash_completion.d/
    /etc/bash_completion.d/info:11:    _expand || return 0
    /etc/bash_completion.d/lrzip:49:    _expand || return 0
    /etc/bash_completion.d/povray:12:    _expand || return 0
    /etc/bash_completion.d/man:21:    _expand || return 0
    /etc/bash_completion.d/xz:53:    _expand || return 0
    /etc/bash_completion.d/lzop:54:    _expand || return 0
    /etc/bash_completion.d/rsync:12:    _expand || return 0
    /etc/bash_completion.d/sshfs:11:    _expand || return 0
    /etc/bash_completion.d/bzip2:37:    _expand || return 0
    /etc/bash_completion.d/ssh:347:    _expand || return 0
    /etc/bash_completion.d/lzma:32:    _expand || return 0
    /etc/bash_completion.d/dd:25:    _expand || return 0
    /etc/bash_completion.d/gcc:19:    _expand || return 0
    /etc/bash_completion.d/findutils:70:    _expand || return 0
    /etc/bash_completion.d/dpkg:29:    _expand || return 0
    /etc/bash_completion.d/gzip:41:    _expand || return 0

If general idea is OK, I will provide full patch.

--- /etc/bash_completion.original    2012-08-14 23:08:38.189654426 +0400
+++ /etc/bash_completion    2012-08-23 01:12:13.313643700 +0400
@@ -1596,7 +1596,7 @@
      COMPREPLY=()
      _get_comp_words_by_ref cur

-    _expand || return 0
+    _rl_enabled expand-tilde && (_expand || return 0)

      # get first exclusion compspec that matches this command
      xspec=$( awk "/^complete[ \t]+.*[ \t]${1##*/}([ \t]|\$)/ { print 
\$0; exit }" \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20120823/61ef4e30/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bash_completion.expand-if-enabled.patch
Type: text/x-patch
Size: 434 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20120823/61ef4e30/attachment.bin>


More information about the Bash-completion-devel mailing list