Why does bash not keeping value of $_ if bash-completion is used in Red Hat Enterprise Linux 8/7?

Solution In Progress - Updated -

Issue

  • In Red Hat Enterprise Linux 6, bash works as expected with bash-completion (fetched from epel) as follows.
[root@rhel6 Data]# rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} = %{VENDOR}\n" | grep bash
bash-4.1.2-48.el6.x86_64 = Red Hat, Inc.
bash-completion-1.3-7.el6.noarch = Fedora Project
[root@rhel6 Data]# touch rpmall.txt rpmshort.txt
[root@rhel6 Data]# mkdir testdir
[root@rhel6 Data]# cp rpmall.txt rpmshort.txt $_
[root@rhel6 Data]# ls $_
rpmall.txt  rpmshort.txt
  • Whereas following doesn't work in Red Hat Enterprise Linux 7 and 8 Beta.
[root@rhel8beta Data]# rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} = %{VENDOR}\n" | grep bash
bash-completion-2.7-5.el8.noarch = Red Hat, Inc.
bash-4.4.19-6.el8.x86_64 = Red Hat, Inc.
[root@rhel8beta Data]# mkdir testdir
[root@rhel8beta Data]# cp rpmall.txt rpmshort.txt $_
cp: target ‘_filedir’ is not a directory
  • Whereas such executions work in Red Hat Enterprise Linux 7 and 8.
[root@rhel8beta ~]# ls -l anaconda-ks.cfg 
-rw-------. 1 root root 2121 Dec  5 18:11 anaconda-ks.cfg
[root@rhel8beta ~]# ls -l $_
-rw-------. 1 root root 2121 Dec  5 18:11 anaconda-ks.cfg
  • Why does bash not keeping value of $_ for some commands?

Environment

  • Red Hat Enterprise Linux 8 beta
    • bash-4.4.19-6.el8.x86_64
    • bash-completion-2.7-5.el8.noarch
  • Red Hat Enterprise Linux 7
    • bash-4.2.46-28.el7.x86_64
    • bash-completion-2.1-6.el7.noarch

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In