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


Groups > gnu.bash.bug > #15310

Re: History not saved when closing terminal while bash is sourcing a script

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: History not saved when closing terminal while bash is sourcing a script
Date Thu, 8 Aug 2019 08:35:25 -0400
Lines 32
Approved bug-bash@gnu.org
Message-ID <mailman.1056.1565267735.1985.bug-bash@gnu.org> (permalink)
References <20190803150529.u5lf2tzvgo5sie7m@nomi.cz> <2b96a07b-c679-ea90-a714-056c81ee0c97@case.edu> <20190808081335.vlcr2ele27hoogue@nomi.cz> <d0fc69f3-38ba-4109-d077-9799eb2ddcee@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
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1565267736 23996 209.51.188.17 (8 Aug 2019 12:35:36 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu, bug-bash@gnu.org
To Tomas Janousek <tomi@nomi.cz>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1565267728; bh=49VWxgsJtZ8FVvnw3n1Ai1CdF4ZScHR6mZQ/P7Nv/Xk=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=tNrwPlMLv3gLqRmyinxqfh6ULs0Erz3/JBPD58RW9tX/gJJox2KE4eK59bgQ6EOKji g7Y3AcJLOjOlD3Y9ewkClgg5+HEHdMj55pTQLJn9tGld9KlkW+pttGfJ3gdgfms2bLp yK8wMNby4b32si5Gs6DQHbeeMx5p3V01Wve+qZ2OXKsWhVphHXl/jBfXQ4XXX9B446X iy4aC1++2rb0mPVdvLBjvuiWntweniU4iRN2LJWK4U3JjMim6xZXNZQxkrHHjSo1P7E KWht4A/7w4dWIV4TyHEnwcWefv0uVWohRrQnIDxfyhU2qMmCR+GTK/DiXWzQZC9D88i bj8tOBjQ==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1565267726; bh=r/Y4q6aQBabGx4NwJsCFaj7HO7PoRLqUByLB0PysOJA=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=NdIDSNJQWB8HLMGSaGFLv9dSO7Om4JAxBSJSDCaYevrSoC/zIGTsKbq8/IYs1KWaU2 +Eys4a75A7cUwIe2mCKlpc5AC4T6+ifOjJC0KY2f89mCRnXo32sROaG0sjD/IouNsO6 iBwsVfcBxFjEV5ZFGEwqH1His2lSsGhbTN7hEwO/V26rbLBxLLxXIHtJwmBQTRAXK29 LqQj/ulVB0QbX+rVy0YQdJwhKP5XSQWFlSE2PZHfSXFPdyJrvMBkwmZ4aA5mkuw/g/6 acsqgVpjtJX96pXcHHvy/eKcGxb5ohmrdxBqWBl1MHad32Rh86H/rGD7IiNNSFMZ5yM Wy4Hqhvw==
Openpgp preference=signencrypt
Autocrypt addr=chet.ramey@case.edu; prefer-encrypt=mutual; keydata= xsDiBEEOsGwRBACFa0A1oa71HSZLWxAx0svXzhOZNQZOzqHmSuGOG92jIpQpr8DpvgRh40Yp AwdcXb8QG1J5yGAKeevNE1zCFaA725vGSdHUyypHouV0xoWwukYO6qlyyX+2BZU+okBUqoWQ koWxiYaCSfzB2Ln7pmdys1fJhcgBKf3VjWCjd2XJTwCgoFJOwyBFJdugjfwjSoRSwDOIMf0D /iQKqlWhIO1LGpMrGX0il0/x4zj0NAcSwAk7LaPZbN4UPjn5pqGEHBlf1+xDDQCkAoZ/VqES GZragl4VqJfxBr29Ag0UDvNbUbXoxQsARdero1M8GiAIRc50hj7HXFoERwenbNDJL86GPLAQ OTGOCa4W2o29nFfFjQrsrrYHzVtyA/9oyKvTeEMJ7NA3VJdWcmn7gOu0FxEmSNhSoV1T4vP2 1Wf7f5niCCRKQLNyUy0wEApQi4tSysdz+AbgAc0b/bHYVzIf2uO2lIEZQNNt+3g2bmXgloWm W5fsm/di50Gm1l1Na63d3RZ00SeFQos6WEwLUHEB0yp6KXluXLLIZitEJM0gQ2hldCBSYW1l eSA8Y2hldC5yYW1leUBjYXNlLmVkdT7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIX gAUCRX3FIgIZAQAKCRC7WGnwZOp0q069AKCNDRn+zzN/AHbaynls/Lvq1kH/RQCgkLvF8bDs maUHSxSIPqzlGuKWDxbOwE0EQQ6wbxAEAJCukwDigRDPhAuI+lf+6P64lWanIFOXIndqhvU1 3cDbQ/Wt5LwPzm2QTvd7F+fcHOgZ8KOFScbDpjJaRqwIybMTcIN0B2pBLX/C10W1aY+cUrXZ gXUGVISEMmpaP9v02auToo7XXVEHC+XLO9IU7/xaU98FL69l6/K4xeNSBRM/AAMHA/wNAmRB pcyK0+VggZ5esQaIP/LyolAm2qwcmrd3dZi+g24s7yjV0EUwvRP7xHRDQFgkAo6++QbuecU/ J90lxrVnQwucZmfz9zgWDkT/MpfB/CNRSKLFjhYq2yHmHWT6vEjw9Ry/hF6Pc0oh1a62USdf aKAiim0nVxxQmPmiRvtCmcJJBBgRAgAJBQJBDrBvAhsMAAoJELtYafBk6nSr43AAn2ZZFQg8 Gs/zUzvXMt7evaFqVTzcAJ0cHtKpP1i/4H4R9+OsYeQdxxWxTQ==
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
In-Reply-To <20190808081335.vlcr2ele27hoogue@nomi.cz>
Content-Language en-US
X-Junkmail-Status score=8/90, host=mpv4-2015.case.edu
X-Junkmail-PrAS-Raw score=8/90, refid=2.7.2:2019.8.8.112716:17:8.317, ip=, rules=DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __SUBJ_REPLY, __PHISH_SPEAR_SUBJ_PREDICATE, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __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_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __COURIER_PHRASE, __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, [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.195
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 <d0fc69f3-38ba-4109-d077-9799eb2ddcee@case.edu>
X-Mailman-Original-References <20190803150529.u5lf2tzvgo5sie7m@nomi.cz> <2b96a07b-c679-ea90-a714-056c81ee0c97@case.edu> <20190808081335.vlcr2ele27hoogue@nomi.cz>
Xref csiph.com gnu.bash.bug:15310

Show key headers only | View raw


On 8/8/19 4:13 AM, Tomas Janousek wrote:
> Hi,
> 
> On Sun, Aug 04, 2019 at 01:42:12PM -0400, Chet Ramey wrote:
>> On 8/3/19 11:05 AM, Tomas Janousek wrote:
>> I don't have or use tmux, but I'm going to guess that `kill-window' sends
>> a SIGHUP to the process group and follows it up with a SIGKILL. The
>> `source' turns off saving to history -- the `source' gets saved in the
>> history list, not the commands it runs -- and is still running when the
>> SIGHUP arrives. The SIGHUP causes the shell to exit without saving the
>> history because history is turned off when the signal handler runs.
> 
> So this means `source' shouldn't ever be used in interactive shells if one
> cares about their shell history, right? 

Or, alternately, one could exit the shell by some means other than sending
it a fatal signal and taking your chances.

I'll file an issue in the Midnight
> Commander bug tracker to use a shell function instead. It might be worth
> documenting the behaviour, though, as it is quite suprising -- shell functions
> don't need to turn off saving to history, so why should `source'?

Because they are parsed and executed separately. Functions are parsed at
definition time and executed when invoked; source scripts are parsed and
executed on the fly a command at a time.

-- 
``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: History not saved when closing terminal while bash is sourcing a script Chet Ramey <chet.ramey@case.edu> - 2019-08-08 08:35 -0400

csiph-web