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


Groups > gnu.bash.bug > #14583 > unrolled thread

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

Started byChet Ramey <chet.ramey@case.edu>
First post2018-09-15 14:52 -0400
Last post2018-09-15 14:52 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Unexpected "!$" history expansion after use of here-document Chet Ramey <chet.ramey@case.edu> - 2018-09-15 14:52 -0400

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

FromChet Ramey <chet.ramey@case.edu>
Date2018-09-15 14:52 -0400
SubjectRe: Unexpected "!$" history expansion after use of here-document
Message-ID<mailman.823.1537038476.1284.bug-bash@gnu.org>
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
newlines.

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
bash.

Chet

-- 
``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/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web