You are not logged in.

#1 2011-03-10 10:33:10

Viper_Scull
Member
From: London, UK
Registered: 2011-01-15
Posts: 153

bash 4.2.006 does not save history

Well not exactly.

If you type exit or press Ctrl +d, if does, but when closing with the button it doesnt. It just does not add lines to history

If there is no bash_history file, it does not create it.

Found a patch:

*** ../bash-4.2-patched/sig.c    Tue Nov 23 08:21:22 2010
--- sig.c    Tue Mar  8 21:28:32 2011
***************
*** 47,50 ****
--- 47,51 ----
  #if defined (READLINE)
  #  include "bashline.h"
+ #  include <readline/readline.h>
  #endif
  
***************
*** 63,66 ****
--- 64,68 ----
  extern int history_lines_this_session;
  #endif
+ extern int no_line_editing;
  
  extern void initialize_siglist ();
***************
*** 506,510 ****
  #if defined (HISTORY)
        /* XXX - will inhibit history file being written */
!       history_lines_this_session = 0;
  #endif
        terminate_immediately = 0;
--- 508,515 ----
  #if defined (HISTORY)
        /* XXX - will inhibit history file being written */
! #  if defined (READLINE)
!       if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0))
! #  endif
!         history_lines_this_session = 0;
  #endif
        terminate_immediately = 0;

Last edited by Viper_Scull (2011-03-10 10:44:55)


Athlon II X4 620 + Gigabyte 785GPM-UD2H + 4GB DDR3 + SSD OCZ Vertex2 60GB

Archlinux x86_64 + Openbox

Offline

#2 2011-03-10 10:55:18

ilpianista
Fellow developer
Registered: 2007-10-06
Posts: 568
Website

Re: bash 4.2.006 does not save history

Offline

#3 2011-03-10 10:59:15

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,672
Website

Re: bash 4.2.006 does not save history

If you are going to post a patch, please post the comment about the patch made by the lead developer of bash when he posted it:

"Yes, I know that it's not 100% safe and will run unsafe functions from a signal handler."

Puts a new perspective on it...

Offline

#4 2011-03-10 11:17:50

Viper_Scull
Member
From: London, UK
Registered: 2011-01-15
Posts: 153

Re: bash 4.2.006 does not save history

Allan wrote:

If you are going to post a patch, please post the comment about the patch made by the lead developer of bash when he posted it:

"Yes, I know that it's not 100% safe and will run unsafe functions from a signal handler."

Puts a new perspective on it...


You are absolutely right.

Can you share then your perspective on this specific patch?
I'll stick to "exit command" if it may damage something.


Athlon II X4 620 + Gigabyte 785GPM-UD2H + 4GB DDR3 + SSD OCZ Vertex2 60GB

Archlinux x86_64 + Openbox

Offline

#5 2011-03-10 11:29:44

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,672
Website

Re: bash 4.2.006 does not save history

My thoughts only extend to if the upstream developer has concerns about the patch, then so do I...  and it will not make the Arch package until upstream says it is OK.

Saying that, the patch is probably good and fairly low risk.   But I'd just try and use "exit" or "ctrl+d" for the time being.

Offline

#6 2011-03-10 12:11:49

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: bash 4.2.006 does not save history

I can't test it with a button, but I got the same behavior with xprop (PID of urxvt) kill -9 PID.

It seems to work with this though, maybe you can try putting it in .bashrc:
trap exit TERM HUP

edit: changed INT to TERM (apparently, it's HUP anyway though...)

Last edited by Procyon (2011-03-10 12:48:14)

Offline

#7 2011-03-10 14:06:36

Viper_Scull
Member
From: London, UK
Registered: 2011-01-15
Posts: 153

Re: bash 4.2.006 does not save history

Procyon wrote:

I can't test it with a button, but I got the same behavior with xprop (PID of urxvt) kill -9 PID.

It seems to work with this though, maybe you can try putting it in .bashrc:
trap exit TERM HUP

edit: changed INT to TERM (apparently, it's HUP anyway though...)

It works.
Thank you Procyon.


Athlon II X4 620 + Gigabyte 785GPM-UD2H + 4GB DDR3 + SSD OCZ Vertex2 60GB

Archlinux x86_64 + Openbox

Offline

Board footer

Powered by FluxBB