[Bash-completion-devel] [bash-completion-Bugs][312759] mutt completion: tilde in quoted command path is not expanded, resulting in bash error

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Mon Apr 25 10:50:07 UTC 2011


Bugs item #312759, was changed at 2010-10-12 18:07 by Ville Skyttä 
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312759&group_id=100114

>Status: Closed
Priority: 3
Submitted By: Nobody (None)
>Assigned to: Ville Skyttä  (scop-guest)
Summary: mutt completion: tilde in quoted command path is not expanded, resulting in bash error 
Distribution: Ubuntu
Originally reported in: None
>Milestone: 2.0
>Status: Fix Committed
Original bug number: 


Initial Comment:
Problem: Typing
    mutt s<TAB>
results in the error
    bash: ~/.mutt/muttquery: No such file or directory

Reason:
* _muttquery in /etc/bash_completion.d/mutt calls
      mutt -Q query_command
  which returns the string
      query_command="~/.mutt/muttquery '%s'"
* From this string, the commandline
      '~/.mutt/muttquery' ''\''s'\'''
  is constructed; note that the command is quoted, including the tilde.
* bash does not expand tilde to the home dir, since it is quoted, and prints the above error message.

Setting:
- Ubuntu 10.10
- bash-completion (1:1.2-2ubuntu1, corresponds to bash-completion-1.2 from alioth)
- bash (4.1-2ubuntu4)
- mutt (1.5.20-9ubuntu2)
- ~/.mutt/muttrc contains the line
set query_command = "$HOME/.mutt/muttquery '%s'"
(Replacing $HOME by the full path does not change anything, since mutt replaces it by tilde.)

Trace (HOMEDIR denotes the full path to the home directory, i.e., equivalent to $HOME or ~):
$ set -x
$ mutt s<TAB>
+ local cur prev
+ _get_comp_words_by_ref -n '=+!' cur prev
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n '=+!' cur prev
+ case $flag in
+ exclude='=+!'
+ getopts c:i:n:p:w: flag -n '=+!' cur prev
+ [[ 4 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ let 'OPTIND += 1'
+ [[ 4 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ let 'OPTIND += 1'
+ [[ 4 -ge 5 ]]
+ __get_cword_at_cursor_by_ref '=+!' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '=+!' words cword
+ local exclude i j ref
+ [[ -n =+! ]]
+ exclude==
+ eval cword=1
++ cword=1
+ [[ -n = ]]
+ (( i=0, j=0 ))
+ (( i < 2 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ eval 'words[0]=${!ref}${COMP_WORDS[i]}'
++ words[0]=mutt
+ '[' 0 = 1 ']'
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 1 -gt 0 ]]
+ [[ -n s ]]
+ [[ '' == s ]]
+ ref='words[1]'
+ eval 'words[1]=${!ref}${COMP_WORDS[i]}'
++ words[1]=s
+ '[' 1 = 1 ']'
+ [[ -n s ]]
+ eval cword=1
++ cword=1
+ (( i++, j++ ))
+ (( i < 2 ))
+ local i cur2
+ local 'cur=mutt s'
+ local index=6
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 6 -ge 4 ]]
+ [[ mutt != \m\u\t\t ]]
+ [[ 0 -lt 1 ]]
+ local old_size=6
+ cur=' s'
+ local new_size=2
+ index=2
+ (( ++i  ))
+ (( i <= cword ))
+ [[ 2 -ge 1 ]]
+ [[   != \s ]]
+ cur=s
+ (( index-- ))
+ [[ 1 -ge 1 ]]
+ [[ s != \s ]]
+ [[ 1 -lt 1 ]]
+ (( ++i  ))
+ (( i <= cword ))
+ [[ s != \s ]]
+ cur2=s
+ local words cword cur
+ _upvars -a2 words mutt s -v cword 1 -v cur s
+ ((  10  ))
+ ((  10  ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ ((  6  ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ ((  3  ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=s
+ shift 3
+ ((  0  ))
+ [[ -n cur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -n '' ]]
+ [[ -n prev ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -n '' ]]
+ ((  2  ))
+ local cur prev
+ _upvars -v cur s -v prev mutt
+ ((  6  ))
+ ((  6  ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=s
+ shift 3
+ ((  3  ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
++ prev=mutt
+ shift 3
+ ((  0  ))
+ COMPREPLY=()
+ case $cur in
+ case $prev in
+ _muttaddr s
+ _muttaliases s
+ local cur=s muttrc muttcmd=mutt
+ local -a conffiles aliases
++ _muttrc
++ set -- mutt s
++ '[' 2 -gt 0 ']'
++ '[' mu = -F ']'
++ shift
++ '[' 1 -gt 0 ']'
++ '[' s = -F ']'
++ shift
++ '[' 0 -gt 0 ']'
++ '[' -z '' ']'
++ '[' -f HOMEDIR/.mutt/muttrc ']'
++ muttrc='~/.mutt/muttrc'
++ '[' -f HOMEDIR/.muttrc ']'
++ printf %s '~/.mutt/muttrc'
+ muttrc='~/.mutt/muttrc'
+ '[' -z '~/.mutt/muttrc' ']'
+ conffiles=($(eval _muttconffiles $muttrc $muttrc))
++ eval _muttconffiles '~/.mutt/muttrc' '~/.mutt/muttrc'
+++ _muttconffiles HOMEDIR/.mutt/muttrc HOMEDIR/.mutt/muttrc
+++ local file sofar
+++ local -a newconffiles
+++ sofar=' HOMEDIR/.mutt/muttrc '
+++ shift
+++ [[ -n HOMEDIR/.mutt/muttrc ]]
+++ newconffiles=($(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ))
+++++ eval echo HOMEDIR/.mutt/muttrc
++++++ echo HOMEDIR/.mutt/muttrc
++++ sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' HOMEDIR/.mutt/muttrc
+++ shift
+++ [[ -n '' ]]
+++ printf '%s\n' HOMEDIR/.mutt/muttrc
+ aliases=($( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p'         $(eval echo "${conffiles[@]}") ))
+++ eval echo HOMEDIR/.mutt/muttrc
++++ echo HOMEDIR/.mutt/muttrc
++ sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' HOMEDIR/.mutt/muttrc
+ COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "${aliases[*]}" -- "$cur" ))
++ compgen -W 'ALIASES REMOVED FOR PRIVACY REASONS' -- s
+ return 0
+ _muttquery s
+ local cur=s querycmd muttcmd=mutt
+ local -a queryresults
++ mutt -Q query_command
++ sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|s|'
+ querycmd='~/.mutt/muttquery '\''s'\'''
+ [[ -z s ]]
+ [[ -z ~/.mutt/muttquery 's' ]]
+ queryresults=($( $querycmd |             sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p' ))
++ '~/.mutt/muttquery' ''\''s'\'''
++ sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p'
bash: ~/.mutt/muttquery: No such file or directory
+ COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "${queryresults[*]}"         -- "$cur" ))
++ compgen -W '' -- s
+ return 0
+ COMPREPLY=("${COMPREPLY[@]}" $( compgen -u -- "$1" ))
++ compgen -u -- s
+ return 0
+ return 0



----------------------------------------------------------------------

>Comment By: Ville Skyttä  (scop-guest)
Date: 2011-04-25 13:50

Message:
Thanks for the detailed bug report.

http://git.debian.org/?p=bash-completion/bash-completion.git;a=commitdiff;h=f5d49065d2be794e8fc486f54f5fb43aafb6956e

----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312759&group_id=100114



More information about the Bash-completion-devel mailing list