Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15634

Re: What should be the expected behavior for $_ ?

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: What should be the expected behavior for $_ ?
Date 2019-11-25 09:33 -0500
Message-ID <mailman.2579.1574692426.13325.bug-bash@gnu.org> (permalink)
References <880841828.14107306.1522764210557.JavaMail.zimbra@redhat.com> <2fbd26f8-811a-579b-7799-e2e8c6532840@case.edu> <5AC41639.6010006@tlinx.org> <621305317.18102863.1574691664255.JavaMail.zimbra@redhat.com> <3a6620a7-0d5d-97c9-58ac-47419ddfbfb1@case.edu>

Show all headers | View raw


On 11/25/19 9:21 AM, Siteshwar Vashisht wrote:

>>> It's an interesting question. You want $_ to expand to the last argument
>>> (or last word) of the previous history entry when the shell is interactive,
>>> which is available as !$, instead of the last command executed by the
>>> current shell instance.
>>>
>>> Should the command line know about shell functions and commands executed in
>>> the foreground on its behalf? What should the behavior be in a
>>> non-interactive shell? What do folks think?
> 
> Can we at least document this behavior in man page if we can't change it ?

I think the current language works pretty well:

"Subsequently, expands to the last argument to the previous simple
command executed in the foreground, after expansion."

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: What should be the expected behavior for $_ ? Chet Ramey <chet.ramey@case.edu> - 2019-11-25 09:33 -0500

csiph-web