Bash Manual says (manpage, my emphasis):
When Bash invokes an external command, the variable
$_is set to the full pathname of the command and passed to that command in its environment.
And (Special Parameters):
$_, 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.
In a bash shell, I run:
$ bash $ export | grep '_='
According to the manual,
_should be an environment variable of the new bash shell.
exportis supposed to output all the environment variables of the new bash shell, but it doesn't output
_. So I wonder whether
_is an environment variable of the new bash shell?
Actually in any bash shell, the same thing happens
$ export | grep '_='
doesn't output anything. So I wonder if
_is ever an environment variable of a bash shell?
$ dash $ export | grep '_=' export _='/bin/dash'