public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: close cygwin window - bash doesnt save history
@ 2002-07-10  7:18 Barry Buchbinder
  2002-07-10  9:03 ` Dario Alcocer
  0 siblings, 1 reply; 13+ messages in thread
From: Barry Buchbinder @ 2002-07-10  7:18 UTC (permalink / raw)
  To: info; +Cc: cygwin

Solution: Don't hit the 'X' button.  Don't get out of
bash by turn off the power, either.  Use "logout" or
"exit".

Bash obviously does not save history after each
command; it saves history when it shuts down.  Hitting
the 'X' button kills it without going through the
normal shut down sequence.

- Barry

-----Original Message-----
From: Shane Brooks [mailto:info@litepc.com]
Sent: Wednesday, July 10, 2002 7:51 am
To: cygwin@cygwin.com
Subject: close cygwin window - bash doesnt save
history

I've been using cygwin for a while now on Windows 2000
and now Windows 
XP - I have updated to the latest version of Cygwin.

If I type "logout", the BASH history is saved and the
window closes.

If I close the cygwin window by hitting the 'X' button
in the windows titlebar 
the Bash History is not saved though I wish it was. -
is there a solution to 
this minor annoyance?

Shane


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: close cygwin window - bash doesnt save history
@ 2002-07-13  7:05 Shane Brooks
  2002-07-13  7:11 ` Randall R Schulz
  0 siblings, 1 reply; 13+ messages in thread
From: Shane Brooks @ 2002-07-13  7:05 UTC (permalink / raw)
  To: cygwin

From: Randall R Schulz <rrschulz@cris.com>
> (*) In further investigating options using "trap," I discovered I can no 
> longer repeat my earlier success, regardless of whether I use "tty" or not.

I used "history -a" , but it appears the trap is being called when the window closes as I can call "myclosefn" OK.  I have been typing this at the BASH command prompt, not editing a .bash_login or profile. So my session looks like..

Shane@GUINNESS ~
$ myclose () {
> history -a
> }

Shane@GUINNESS ~
$ trap myclosefn SIGHUP

Shane@GUINNESS ~
$

using shopt I see that the builtin command huponexit is OFF, but that should be OK shouldnt it?  the man page suggests huponexit allows tasks that are not in the job table to recieve the SIGHUP also.

from the man page "When Bash receives a signal for which a trap has been set while waiting for a command to complete, the trap will not be executed until the command completes." - perhaps under windows its too late once the command has completed?  ie the window is already closed?

Interestingly I see something flash onto the command line just before the window closes..but my machine is too fast to allow me to read it.


-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Save up to $160 by signing up for NetZero Platinum Internet service.
http://www.netzero.net/?refcd=N2P0602NEP8


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: close cygwin window - bash doesnt save history
@ 2002-07-13  5:45 Shane Brooks
  2002-07-13 10:16 ` Dario Alcocer
  0 siblings, 1 reply; 13+ messages in thread
From: Shane Brooks @ 2002-07-13  5:45 UTC (permalink / raw)
  To: cygwin


----- Original Message -----
From: Dario Alcocer <alcocer@helixdigital.com>
> On Thu, Jul 11, 2002 at 01:26:01AM -0500, Shane Brooks wrote:
[snip]
> >  sounds great but perhaps I dont understand the answer - I'm not a programmer or unix boy.  I tried typing the following in a bash session but it didnt execute the exit statement when I closed the window.
> > 
> > $ myclosefn() {
> > > exit
> > > }
> > 
> > $ trap myclosefn SIGHUP
> 
> Well, exit by itself won't do what you want.  If you read the bash
> manpage, you'll see that there are several environment variables
> that control history.  I invite you to read HISTORY (not yelling,
> manpage section names are in caps) in the bash manpage.  I *assure*
> you, your question *will* be answered by a careful reading.
> 
> I like to think that one of the preconditions of using Unix-like
> tools like Cygwin is the user must be prepared to read manpages and
> examples to accomplish the task at hand and expand their mastery
> of the environment.

I couln't agree with you more.  I have read the bash man pages several times over though I dont understand it all. I have also checked the environment variables that control history several times over.  My cygwin install is bog standard as far as BASH is concerned. History works as expected under all conditions other than trying to follow your advice above.  "exit" *does* do exactly what I want if I type it at the bash command prompt (ie it saves the history, logs out of the bash session and the WindowsXP command window closes.  I assumed that calling "exit" from the trap command may also lead the the history being saved.

Believe me - we aren't all newbies looking for a quick lazy fix - but at some stage we *are* all newbies.

I dont have the TTY env var set...but thats another thread. 

Still tryin'

Shane
-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Save up to $160 by signing up for NetZero Platinum Internet service.
http://www.netzero.net/?refcd=N2P0602NEP8


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: close cygwin window - bash doesnt save history
@ 2002-07-11  5:10 Schaible, Jorg
  0 siblings, 0 replies; 13+ messages in thread
From: Schaible, Jorg @ 2002-07-11  5:10 UTC (permalink / raw)
  To: cygwin

Hi Shane,

>If I close the cygwin window by hitting the 'X' button in the 
>windows titlebar 
>the Bash History is not saved though I wish it was. - is there 
>a solution to 
>this minor annoyance?

don't use the X button, just type CTRL-D.

Regards,
Jorg

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: close cygwin window - bash doesnt save history
@ 2002-07-11  3:30 Shane Brooks
  2002-07-11  9:10 ` Dario Alcocer
  2002-07-11  9:11 ` Randall R Schulz
  0 siblings, 2 replies; 13+ messages in thread
From: Shane Brooks @ 2002-07-11  3:30 UTC (permalink / raw)
  To: cygwin


----- Original Message -----
From: Dario Alcocer <alcocer@helixdigital.com>
Date: Wed, 10 Jul 2002 08:17:50 -0700
To: cygwin@cygwin.com
Subject: Re: close cygwin window - bash doesnt save history
 
> Even better solution: register a signal handler in your Bash session
> for SIGHUP; the cygwin1.dll sends a hangup signal when CTRL_CLOSE_EVENT
> is received.  Something like this:
> 
>     $ myclosefn() {
>         echo "My close func got called." > $HOME/myclosefn.txt
>         # TODO: add more clean-up logic here
>     }
>     $ trap myclosefn SIGHUP
> 
> I've tested this, so I know it works.

 sounds great but perhaps I dont understand the answer - I'm not a programmer or unix boy.  I tried typing the following in a bash session but it didnt execute the exit statement when I closed the window.

$ myclosefn() {
> exit
> }

$ trap myclosefn SIGHUP

I guess Im hoping to find something I can put in my profile or bashrc that will behave as above to automagically perform the "exit" and save the history.
-- 
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

Save up to $160 by signing up for NetZero Platinum Internet service.
http://www.netzero.net/?refcd=N2P0602NEP8


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* close cygwin window - bash doesnt save history
@ 2002-07-10  5:35 Shane Brooks
  0 siblings, 0 replies; 13+ messages in thread
From: Shane Brooks @ 2002-07-10  5:35 UTC (permalink / raw)
  To: cygwin

I've been using cygwin for a while now on Windows 2000 and now Windows 
XP - I have updated to the latest version of Cygwin.

If I type "logout", the BASH history is saved and the window closes.

If I close the cygwin window by hitting the 'X' button in the windows titlebar 
the Bash History is not saved though I wish it was. - is there a solution to 
this minor annoyance?

Shane



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-07-13 12:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-10  7:18 close cygwin window - bash doesnt save history Barry Buchbinder
2002-07-10  9:03 ` Dario Alcocer
  -- strict thread matches above, loose matches on Subject: below --
2002-07-13  7:05 Shane Brooks
2002-07-13  7:11 ` Randall R Schulz
2002-07-13  5:45 Shane Brooks
2002-07-13 10:16 ` Dario Alcocer
2002-07-11  5:10 Schaible, Jorg
2002-07-11  3:30 Shane Brooks
2002-07-11  9:10 ` Dario Alcocer
2002-07-11  9:11 ` Randall R Schulz
2002-07-11  9:29   ` Dario Alcocer
2002-07-11 10:27     ` Randall R Schulz
2002-07-10  5:35 Shane Brooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).