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


Groups > gnu.bash.bug > #15612

Re: Issues with history substitution and its documentation

Path csiph.com!weretis.net!feeder6.news.weretis.net!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: Issues with history substitution and its documentation
Date Tue, 19 Nov 2019 09:50:15 -0500
Lines 34
Approved bug-bash@gnu.org
Message-ID <mailman.1961.1574175026.13325.bug-bash@gnu.org> (permalink)
References <CA+VKLw-WX8zUz06MZ9ThuMhUuW97aJ5ted8oSfJSvrVJBLW3hA@mail.gmail.com> <CA+VKLw_XMx1xjiFt-Tio8S+Mdt_AeS9v64SuMYYMdDdDnJFSBQ@mail.gmail.com> <CA+VKLw_hceb_xzu7kzTJAVuegWzqxJDa8xw4ja5TOBPpOWvRDQ@mail.gmail.com> <CA+VKLw_dh_SgozSCqqeg0SBTacx6PyobJff6Thu6uuV-LPCdeQ@mail.gmail.com> <CA+VKLw9c9B5FNg=48rE1v=mjZ-9Xnj9hyeyuJ0LcOYJZiMp=rQ@mail.gmail.com> <8e690ee5-4afd-e45d-f3c5-8a69f61139dd@case.edu> <CA+VKLw9CsVJxSCKDB4=_Jd=w3SrutiB2G7k1WX8g8h8-EjggpQ@mail.gmail.com> <7cd16ba9-096c-b741-f3ba-2b993b09fe75@case.edu>
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1574175027 31079 209.51.188.17 (19 Nov 2019 14:50:27 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu, bug-bash@gnu.org
To Jim Monte <jim.monte01@gmail.com>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1574175017; bh=jkL2ZXqYNYHPQsMGGMkL+EOC7+0W/MgySWf+K8dmWX4=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=qGKB4WMyTENOn7uItbmWEadIS1k38xytWTRRjyI+Nno1ULSEgHBqfReSVGlK22o+xM //6YnO+8X5uptWNPJUnfLVEMCmDYK28a20OW/HN38CW3xzdYhTUI68wfF7nqxX8iolr jskSCbFrGSqGrXilu6xT97IqgkBTV08lVCCg82xmcWtcdNDVhDHuanX0JV1vgBs6uSb yNBsTxv3Jm9Z3i/+kyg0bTp11sIxxPtZY1j8q7AQ668LYZ02BuFLbuQgjmM+s/7xkEB BYObWaTnCZsBrNmSH9zy6bcku66tUT9p58GbmiptxLPA8qIILkI+e+fMZse4uAcINo/ HGTY2iwQ==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1574175016; bh=ikDi4vVQ35Fp4LreBxenGOopYqd6xaC1GwAhaXoxD/c=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=L2vAOEDAPLWUAiyCQ4EPQEIAPvyw5CvZ+AX3zkEUQRE1rw3SmE1d3W842Snwf/oY3N pi3yg/3lw5hA+ec4h7IwBpEu2cy0dmUSxRy852RnwXgGmB/ySnCH0tL4sz0r1x6owNh 0HIMi+aTigYXRk+APPVjz2dYEdETlJZ0Tq8yRbtOhmpFY738dQNkMs8uOM29MHFAuAk XG6Cf1BazBhbc5o4M6Uo/lI1LN7cIsBGnW49mC7WfnZX4im3gxT0sjoUcvkMnIVF08+ Ofjs1WdmNXoEyPPVW29GGPYS1UrMxD+YSIqZj1MXBuHtldB+mDfEsMbe67Kiau8kO/E wDsBkGYw==
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.2
In-Reply-To <CA+VKLw9CsVJxSCKDB4=_Jd=w3SrutiB2G7k1WX8g8h8-EjggpQ@mail.gmail.com>
Content-Language en-US
X-Junkmail-Status score=8/90, host=mpv2-2015.case.edu
X-Junkmail-PrAS-Raw score=8/90, refid=2.7.2:2019.11.19.135116:17:8.317, ip=, rules=DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __SUBJ_REPLY, __PHISH_SPEAR_SUBJ_ALERT, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __HAS_REFERENCES, __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_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __DKIM_ALIGNS_1, __DKIM_ALIGNS_2, __ANY_URI, __URI_MAILTO, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __BODY_NO_MAILTO, __NO_HTML_TAG_RAW, BODY_SIZE_1500_1599, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, DKIM_ALIGNS, [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] [fuzzy]
X-Received-From 129.22.103.227
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
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 <https://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>
X-Mailman-Original-Message-ID <7cd16ba9-096c-b741-f3ba-2b993b09fe75@case.edu>
X-Mailman-Original-References <CA+VKLw-WX8zUz06MZ9ThuMhUuW97aJ5ted8oSfJSvrVJBLW3hA@mail.gmail.com> <CA+VKLw_XMx1xjiFt-Tio8S+Mdt_AeS9v64SuMYYMdDdDnJFSBQ@mail.gmail.com> <CA+VKLw_hceb_xzu7kzTJAVuegWzqxJDa8xw4ja5TOBPpOWvRDQ@mail.gmail.com> <CA+VKLw_dh_SgozSCqqeg0SBTacx6PyobJff6Thu6uuV-LPCdeQ@mail.gmail.com> <CA+VKLw9c9B5FNg=48rE1v=mjZ-9Xnj9hyeyuJ0LcOYJZiMp=rQ@mail.gmail.com> <8e690ee5-4afd-e45d-f3c5-8a69f61139dd@case.edu> <CA+VKLw9CsVJxSCKDB4=_Jd=w3SrutiB2G7k1WX8g8h8-EjggpQ@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15612

Show key headers only | View raw


On 11/18/19 12:40 PM, Jim Monte wrote:
> Thank you for looking into all of these reports. My issue here was that in 
> both cases there had not yet been any ?string? search, so they should 
> behave the same way -- an event is not required to not have a most recent 
> ?string? search. So if the default is to use an empty string as the 
> previous string when there is none, for consistency from the perspective of 
> the user, both instances of echo "!%" should output echo "" as the second 
> one does.

That's not the issue. The `%' isn't part of the event selector; it's a
word designator. The `real' event is `!!', though it's abbreviated as `!'.
This is essentially equivalent to "!!:%".

Since the event selector is `!!', you need a previous history entry to
make that a valid event, and you don't have one. The history code complains
when you specify an invalid event -- it's the same as if you had specified
"!578" when you only have 12 history entries.

> [root@localhost ~]# bash
> [root@localhost ~]# echo "!%"
> bash: !: event not found
> [root@localhost ~]# echo a >/dev/nul
> [root@localhost ~]# echo "!%"
> echo ""

I don't know if you're not reading the history file at startup or if it's
due to something else, but you have an empty history list when you attempt
the first history 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: Issues with history substitution and its documentation Chet Ramey <chet.ramey@case.edu> - 2019-11-19 09:50 -0500

csiph-web