Bug 879671

Summary: Bash completion doesn't escape characters any more
Product: [openSUSE] openSUSE 13.1 Reporter: Tristan Miller <psychonaut>
Component: OtherAssignee: Dr. Werner Fink <werner>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: psychonaut, qantas94heavy
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: openSUSE 13.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Tristan Miller 2014-05-23 14:06:36 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26

I just upgraded from bash-completion-2.0-2.1.1 to bash-completion-2.1-3.1.2 and found that with many commands, filenames containing spaces and other special characters are no longer correctly escaped.  They are correctly escaped with some commands, such as cd and mv, but with others, such as tar and pdftk, they are not.


Reproducible: Always

Steps to Reproduce:
1. In a bash terminal, type the following and press enter:

touch "this is a test.txt"

2. In a bash terminal, type the following and press tab:

tar -c -v -f /tmp/test.tar this

Actual Results:  
3. The command line expands to the following:

tar -c -v -f /tmp/test.tar this is a test.txt


Expected Results:  
3. The command line should expand to the following:

tar -c -v -f /tmp/test.tar this\ is\ a\ test.txt
Comment 1 Dr. Werner Fink 2014-05-26 06:55:28 UTC
Can not reproduce:

 linux:~ # touch "this is a test.txt"
 linux:~ # tar -c -v -f /tmp/test.tar this<TAB>
 linux:~ # tar -c -v -f /tmp/test.tar this\ is\ a\ test.txt
 linux:~ # rpm -qi bash-completion
 Name        : bash-completion
 Version     : 2.1
 Release     : 3.1.2
 Architecture: noarch
 Install Date: Wed Nov  6 08:52:30 2013
 Group       : System/Shells
 Size        : 718352
 License     : GPL-2.0+
 Signature   : RSA/SHA256, Fri Sep 27 22:18:22 2013, Key ID b88b2fd43dbdc284
 Source RPM  : bash-completion-2.1-3.1.2.src.rpm
 Build Date  : Fri Sep 27 22:18:03 2013
 Build Host  : cloud136
 Relocations : (not relocatable)
 Packager    : http://bugs.opensuse.org
 Vendor      : openSUSE
 URL         : http://bash-completion.alioth.debian.org/
 Summary     : Programmable Completion for Bash
 Description :
 bash-completion is a collection of shell functions that take advantage
 of the programmable completion feature of Bash 2.04 and later.
 Distribution: openSUSE 13.1
Comment 2 Tristan Miller 2014-06-04 09:06:04 UTC
Werner, my output of rpm -ql bash-completion is exactly the same as yours.  What further information do you think I could provide which might help diagnose the problem?
Comment 3 Dr. Werner Fink 2014-06-04 09:37:13 UTC
The output of the commands:

   tar <TAB>
   complete -p | grep tar
   locale
   echo "$COMP_WORDBREAKS"
   echo -n "$COMP_WORDBREAKS" | wc -c
   shopt
Comment 4 Tristan Miller 2014-06-04 10:07:20 UTC
# tar <TAB>

This produces nothing.  tar <TAB><TAB> produces the following:
A c d r t u x

# complete -p | grep tar
complete -F _service /etc/init.d/vboxautostart-service
complete -F _tar tar

# locale
LANG=en_CA.utf8
LC_CTYPE="en_CA.utf8"
LC_NUMERIC="en_CA.utf8"
LC_TIME="en_CA.utf8"
LC_COLLATE="en_CA.utf8"
LC_MONETARY="en_CA.utf8"
LC_MESSAGES=en_CA.UTF-8
LC_PAPER="en_CA.utf8"
LC_NAME="en_CA.utf8"
LC_ADDRESS="en_CA.utf8"
LC_TELEPHONE="en_CA.utf8"
LC_MEASUREMENT="en_CA.utf8"
LC_IDENTIFICATION="en_CA.utf8"
LC_ALL=

# echo "$COMP_WORDBREAKS"
 
"'><=;|&(:

# echo -n "$COMP_WORDBREAKS" | wc -c
13

# shopt
autocd          off
cdable_vars     off
cdspell         off
checkhash       off
checkjobs       off
checkwinsize    on
cmdhist         on
compat31        off
compat32        off
compat40        off
compat41        off
direxpand       off
dirspell        off
dotglob         off
execfail        off
expand_aliases  on
extdebug        off
extglob         on
extquote        on
failglob        off
force_fignore   on
globstar        off
gnu_errfmt      off
histappend      on
histreedit      off
histverify      off
hostcomplete    off
huponexit       off
interactive_comments    on
lastpipe        off
lithist         off
login_shell     on
mailwarn        off
no_empty_cmd_completion off
nocaseglob      off
nocasematch     off
nullglob        off
progcomp        on
promptvars      on
restricted_shell        off
shift_verbose   off
sourcepath      on
xpg_echo        off
Comment 5 Dr. Werner Fink 2014-06-04 10:20:50 UTC
Update osc to latest if you've this installed as IMHO the command

   echo "$COMP_WORDBREAKS"

should return

 linux:~ # echo "$COMP_WORDBREAKS"
  
 "'><=;|&(
 linux:~ #

that is newline followed by space and then by "'><=;|&(

Beside this, what does the command

 compopt -D

show?
Comment 6 Tristan Miller 2014-06-04 12:56:26 UTC
I don't have osc installed.

# compopt -D
compopt +o bashdefault +o default +o dirnames +o filenames +o nospace +o plusdirs -D

Perhaps this is a better way of showing my value of $COMP_WORDBREAKS:

# echo -n "$COMP_WORDBREAKS" | hexdump
0000000 0920 220a 3e27 3d3c 7c3b 2826 003a     
000000d
Comment 7 Dr. Werner Fink 2014-06-04 13:00:40 UTC

linux:~ # echo -n "$COMP_WORDBREAKS" | hexdump
0000000 0920 220a 3e27 3d3c 7c3b 2826          
000000c
Comment 8 Tristan Miller 2014-06-10 14:30:40 UTC
Yes, the value of $COMP_WORDBREAKS seems to differ slightly, but I don't know if that's the cause of the problem.  Any other ideas?

Is there anywhere I can download the old bash-completion-2.0-2.1.1 RPM so that I can compare files?
Comment 9 Dr. Werner Fink 2014-06-10 14:42:34 UTC
There is no old bash-completion-2.0-2.1.1 ... please check for COMP_WORDBREAKS in your personal ~/.bashrc and ~/.profile as well as below

        /etc/profile.d/
        /usr/share/bash-completion/

with the command

        grep COMP_WORDBREAKS=

to see where it beomes reassigned
Comment 10 Tristan Miller 2014-06-10 16:15:37 UTC
COMP_WORDBREAKS is not assigned anywhere in ~/.bashrc, ~/.profile, /etc/profile.d, or /usr/share/bash-completion.  It's also not assigned in /etc/bash_completion.d nor anywhere else in the /etc hierarchy.  As far as I can tell it has whatever default value bash gives it.
Comment 11 Tristan Miller 2014-12-11 13:07:07 UTC
Problem is still reproducible with bash-completion-2.1-5.1.2 on openSUSE 13.2.
Comment 12 Dr. Werner Fink 2014-12-11 13:19:23 UTC
Give openSUSE:Factory/bash-completion a try
Comment 13 Tristan Miller 2014-12-11 13:25:55 UTC
I found the cause of and solution to the problem.

The same issue was reported for Ubuntu at https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/883268 and in Comment #7 of that issue it's reported that Adobe Reader places a file in /etc/bash_completion.d which overrides bash-completion's _filedir().

The solution is to uninstall Adobe Reader (AdobeReader_enu-9.5.5-1.i486).  (Of course, once this is done, it cannot be easily undone, since both Adobe and Novell have stopped distributing the GNU/Linux version of Adobe Reader.)

The bash completion problem described in this bug report doesn't arise with fresh installations of openSUSE 13.1 and 13.2 because Adobe Reader is no longer distributed with those versions.  However, in my case I had been using an earlier version of openSUSE and then upgraded the OS, retaining Adobe Reader.

I'm not sure, but it may be worth updating the openSUSE bash-completion RPM so that it's marked as conflicting with AdobeReader_enu-9.5.5-1.i486, or so that it issues a warning if a user tries to install it and AdobeReader_enu-9.5.5-1.i486 simultaneously.
Comment 14 Tristan Miller 2014-12-11 16:49:32 UTC
Clearing needinfo; this seems irrelevant now given my previous comment.
Comment 15 Karl Cheng 2018-02-22 00:52:44 UTC
Not really that relevant any more given that Adobe Reader hasn't been distributed with openSUSE for many releases now.