[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected "!$" history expansion after use of here-document

From: Chet Ramey
Subject: Re: Unexpected "!$" history expansion after use of here-document
Date: Sat, 15 Sep 2018 14:52:05 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 9/11/18 8:17 PM, Viktor Dukhovni wrote:

> Bash Version: 4.4
> Patch Level: 23
> Release Status: release
> Description:
>       Intuitevely, (and confirmed behaviour of "csh" whose history
>       substitution bash emulates), after a command of the form:
>               $ grep foo <<EOF > /tmp/bar
>               foobar
>               abcdef
>               EOF
>       One would expect "!$" to be /tmp/bar, so that an immediate:
>               $ wc -l !$
>       should expand to "wc -l /tmp/bar" and output "1".

If you're using command-oriented history, which I surmise you are,
the history entry is the entire previous command, with its embedded

The last word is the final newline, since the embedded newlines count
as words (which seems non-intuitive; I will have to look at that).

I don't know what csh does, or why it seemingly throws away the rest
of the command, but that's not how command-oriented history works in


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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]