bugGNU Octave - Bugs: bug #32524, history command overwrites files

 
 

bug #32524: history command overwrites files

Submitted by:  Thorsten Meyer <tmeyier>
Submitted on:  Thu 17 Feb 2011 09:27:42 PM UTC  
 
Category: InterpreterSeverity: 4 - Important
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 23 Aug 2011 09:17:36 PM UTC, comment #1:

I checked in two changes to fix this problem. The first eliminates the variable duplication that you noticed. That was necessary in the dark ages of Octave, but not now. The second changeset should fix the problem you noticed with the history file being overwritten.

http://hg.savannah.gnu.org/hgweb/octave/rev/00235a6446da
http://hg.savannah.gnu.org/hgweb/octave/rev/07dc4839c05f

These changes appear to fix the problem for me, so I'm closing this report.

John W. Eaton <jwe>
Project Administrator
Thu 17 Feb 2011 09:27:42 PM UTC, original submission:

I have been using the command
to write the interactive command history to a file as a start for a new octave script, always assuming that this command would write the history once and leave new_script.m as it is afterwards. After that I used to delete everything except the series of recent commands I was interested in (in new_script.m) and cleaned up the code only to find later that it looked like the raw command history again (and I repeatedly thought I had been really stupid because I forgot to save the changes).
It took me several weeks to realize, that what really happened was that octave wrote the history again to this new_script.m file when I quit the octave session.

So what
apparently does is to write the history to the file immediately and write it to the file again, when the octave session is closed.
This could still be a feature. However, after issuing the above command, the command
still gives
ans = /home/thorsten/.octave_hist

Interestingly, when I explicitly set the history filename with
after the history -w first_file.m command, history is written to some_other_filename when the octave session ends.

While debugging this, I found that the same happens in this example:
I.e., octave appends the content of myfile.m to the history and when the session quits, the complete history is written to myfile.m overwriting its original content.

Attached is a patch, that seems to solve the problem. However, I am quite confused by the fact, that the history file is kept within octave in two locations:
in an internal variable history_file
and
as a property of the command_history object (accessed by command_history::file and command_history::set_file)

Is this really intended? And if yes, does my patch interfere with this cunning scheme in an unwanted way?

regards

Thorsten

Thorsten Meyer <tmeyier>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #22719:  fix_history_bug added by tmeyier (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by tmeyier (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 23 Aug 2011 09:17:36 PM UTCjweStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Thu 17 Feb 2011 09:27:42 PM UTCtmeyierAttached File-=>Added fix_history_bug, #22719

    Back to the top


    Powered by Savane 3.1-cleanup1