Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1382801

Summary: "shopt -s direxpand" should be default
Product: Red Hat Enterprise Linux 7 Reporter: Paulo Andrade <pandrade>
Component: bashAssignee: Siteshwar Vashisht <svashisht>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: jkejda, olchansk, pandrade
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-11 13:37:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1298243, 1420851    

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.