Bug 1382801 - "shopt -s direxpand" should be default
Summary: "shopt -s direxpand" should be default
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: bash
Version: 7.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
: 1376970 (view as bug list)
Depends On:
Blocks: 1298243 1420851
TreeView+ depends on / blocked
 
Reported: 2016-10-07 18:37 UTC by Paulo Andrade
Modified: 2019-12-16 07:02 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-11 13:37:59 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Paulo Andrade 2016-10-07 18:37:28 UTC
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.

Comment 3 Siteshwar Vashisht 2017-01-19 14:28:47 UTC
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 ?

Comment 4 Siteshwar Vashisht 2017-01-20 04:46:58 UTC
So I was missing bash-completion package from my system. I am able to reproduce it now.

Comment 5 Siteshwar Vashisht 2017-02-14 10:44:19 UTC
*** Bug 1376970 has been marked as a duplicate of this bug. ***

Comment 6 Siteshwar Vashisht 2017-07-11 13:37:59 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.