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


Groups > gnu.bash.bug > #14572

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

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Viktor Dukhovni <ietf-dane@dukhovni.org>
Newsgroups gnu.bash.bug
Subject Unexpected "!$" history expansion after use of here-document
Date Tue, 11 Sep 2018 20:17:58 -0400 (EDT)
Lines 69
Approved bug-bash@gnu.org
Message-ID <mailman.661.1536729689.1284.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
X-Trace usenet.stanford.edu 1536729689 23012 208.118.235.17 (12 Sep 2018 05:21:29 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-detected-operating-system by eggs.gnu.org: FreeBSD [generic] [fuzzy]
X-Received-From 100.2.39.101
X-Mailman-Approved-At Wed, 12 Sep 2018 01:21:28 -0400
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14572

Show key headers only | View raw


Configuration Information [Automatically generated, do not change]:
Machine: amd64
OS: freebsd11.1
Compiler: cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='amd64' -DCONF_OSTYPE='freebsd11.1' -DCONF_MACHTYPE='amd64-portbld-freebsd11.1' -DCONF_VENDOR='portbld' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' -DSHELL  -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -DDEFAULT_PATH_VALUE='/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin'  -DSTANDARD_UTILS_PATH='/sbin:/bin:/usr/sbin:/usr/bin' -DLIBICONV_PLUG -I/usr/local/include -O2 -pipe  -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -Wno-parentheses -Wno-format-security
uname output: FreeBSD straasha.imrryr.org 11.1-RELEASE-p10 FreeBSD 11.1-RELEASE-p10 #1 r333375M: Sat Jun 23 17:50:31 EDT 2018     root@straasha.imrryr.org:/usr/obj/usr/src/sys/GENERIC  amd64
Machine Type: amd64-portbld-freebsd11.1

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

	Instead we get:

	    $ PS1='$ '
	    $ PS2=" "
	    $ grep foo <<EOF > /tmp/bar
	     foobar
	     abcdef
	     EOF
	    $ cat !$ > /dev/tty
	    cat 
	     > /dev/tty
	    abc
	    abc
	    123
	    123
	    <CTRL-D>
            $ history 3
	        3  grep foo <<EOF > /tmp/bar
	    foobar
	    abcdef
	    EOF

	        4  cat 
	     > /dev/tty
	        5  history 3

	It looks like "!$" expands to the newline after the EOF in history entry 3.
        The expansion (as in "csh") should be "/tmp/bar".

Repeat-By:

	In interactive shell, expand "!$" after a command that uses a here-document:

	$ grep foo <<EOF > /tmp/bar
        foo
        EOF
        $ echo "--!$++"
	echo "--
	++"
	--
	++

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


Thread

Unexpected "!$" history expansion after use of here-document Viktor Dukhovni <ietf-dane@dukhovni.org> - 2018-09-11 20:17 -0400

csiph-web