[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What should be the expected behavior for $_ ?
From: |
Siteshwar Vashisht |
Subject: |
What should be the expected behavior for $_ ? |
Date: |
Tue, 3 Apr 2018 10:03:30 -0400 (EDT) |
According to bash reference manual[1]:
($_, an underscore.) At shell startup, set to the absolute pathname used to
invoke the shell or shell script being executed as passed in the environment or
argument list. Subsequently, expands to the last argument to the previous
command, after expansion. Also set to the full pathname used to invoke each
command executed and placed in the environment exported to that command. When
checking mail, this parameter holds the name of the mail file.
Now consider following example (with bash-completion package installed):
$ cd /tmp/
$ touch rpmall.txt rpmshort.txt
$ mkdir testdir
$ cp rpmall.txt rpmshort.txt $_ # Use tab completion to complete filenames
cp: target '_filedir' is not a directory
Last command fails because tab completing 'cp' command modifies value of '$_'.
Shall value of '$_' be modified if a command gets executed in background ?
[1]
https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters
--
--
Siteshwar Vashisht
- What should be the expected behavior for $_ ?,
Siteshwar Vashisht <=