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


Groups > gnu.bash.bug > #14583

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

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Unexpected "!$" history expansion after use of here-document
Date Sat, 15 Sep 2018 14:52:05 -0400
Organization ITS, Case Western Reserve University
Lines 40
Approved bug-bash@gnu.org
Message-ID <mailman.823.1537038476.1284.bug-bash@gnu.org> (permalink)
References <20180912001758.239A53745B@straasha.imrryr.org>
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1537038477 21813 208.118.235.17 (15 Sep 2018 19:07:57 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu
To Viktor Dukhovni <ietf-dane@dukhovni.org>, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:cc:subject:to:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=+X24DoUJb5LWl6Kaz1rtJnCKuvdDN9yTirDotG5Rb48=; b=Ep+avTB53zycRSXS8D74uGrYxeN/70USVyBrtNvXeGaRh1Z1WkPv25TrvrjZUB4jNp uZRW5dY3x02uZx5q3IvDyGRLASNI+AyktLe98HhQjK2gRaRJnGA6WhygnQbpom8bWXna jc0DpVmToSEzAfWquoM6mrbjKAPpFoRdNEJqTWD0zV2rBCbjrhbwPpGUGvaa3VYie7+0 ivW6ysyC3E9cISyFiW1SYfCVKKatr8A0UCXt/SxRhr9tC2SZAuo6VHIHTWxytQKhMaXn CvYPLPSMVFpIpRskmKLhMHJq3cwbZTQ+gMA8iH0SF4wrA3XcrBqGFtwlMmR4vxC9Ox7w vfug==
X-Gm-Message-State APzg51BvwKEPgeS1iJNn7dTQxGW4SCBbKM7tO5Cta7jcG2DEfZ84Ls2u ztSfdvtpU/2Y8AL+nK499N/zxcOVUj0HJwg5nhtFW260zYnlVnMu37ZmvLTc2ndLetqe8raCRta 7QUKJyFZGoUY=
X-Received by 2002:a6b:9bd1:: with SMTP id d200-v6mr16429758ioe.147.1537037528092; Sat, 15 Sep 2018 11:52:08 -0700 (PDT)
X-Google-Smtp-Source ANB0VdZw0PPrN03oeOUvr3RT7fORTnu6DC0HXWmHq9CDZaiZPvIRtftpPFGPHxS0CxZCH2nePsvjtA==
X-Received by 2002:a6b:9bd1:: with SMTP id d200-v6mr16429753ioe.147.1537037527863; Sat, 15 Sep 2018 11:52:07 -0700 (PDT)
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
In-Reply-To <20180912001758.239A53745B@straasha.imrryr.org>
Content-Language en-US
X-Junkmail-Status score=7/90, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw score=7/90, refid=2.7.2:2018.9.15.174816:17:7.944, ip=, rules=__YOUTUBE_RCVD, __X_GOOGLE_DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __SUBJ_REPLY, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW, BODY_SIZE_1100_1199, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
X-Received-From 129.22.103.227
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:14583

Show key headers only | View raw


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/

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


Thread

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

csiph-web