Hide Forgot
Bash 4.3 or newer have the configure option --enable-direxpand-default I suggest backporting a small patch, basically what is under "#if DIRCOMPLETE_EXPAND_DEFAULT" from bash 4.3 to rhel7 bash. This would make the behavior identical to rhel6 bash. Example of unexpected behavior: $ sudo su - # cd # mkdir fir # test=/root/fir # echo $test /root/fir # ls $test<press tab> # ls $test [] <<< Adds a space for next entry >>> # ls $test/<press tab> # ls $test/ <<< Nothing happens >>> # touch $test/tree.txt <<<Now the problem:>>> <<<In RHEL 6.8:>>> # ls $test/<press tab> # ls /root/fir/tree.txt <<<Replaces the $test with /root/fir>>> <<<In RHEL 7.2:>>> # ls $test/<press tab> # ls \$test/tree.txt ls: cannot access $test/tree.txt: No such file or directory <<<Adds a \ in front of $test>>> Toying a bit with it shows other strange behavior, for example: # ls '$test'<press tab> # ls '$test'-bash: unexpected EOF while looking for matching `'' -bash: syntax error: unexpected end of file or # ls "$test"/<press tab> tree.txt # ls \$test/tree.txt it removes quotes and adds the leading backslash. I believe the change is better done in bash to match rhel6 behavior, but it could be done in related /etc/skel files (shopt -s direxpand). When updating bash, I suggest adding --enable-direxpand-default to the configure options.
Paulo, I am not able to reproduce this issue. Here is the output from my system : # cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.3 (Maipo) # rpm -q bash bash-4.2.46-20.el7_2.x86_64 # cd /root/ # mkdir fir # test=/root/fir # echo $test /root/fir # touch $test/tree.txt 'ls $test/<TAB>' gives # ls $test/tree.txt No escape character '\' before '$'. # ls '$test'<TAB> I don't get "bash: unexpected EOF while looking for matching `''" # ls "$test"/<press tab> gives : # ls $test/tree.txt Are you able to reproduce it on RHEL-7.3 ?
So I was missing bash-completion package from my system. I am able to reproduce it now.
*** Bug 1376970 has been marked as a duplicate of this bug. ***
This is a behavior change from RHEL 6 to RHEL 7 and it is not a good idea to change behavior during minor releases. Also, it is easy to workaround this behavior by setting "shopt -s direxpand". I am closing it as wontfix.