[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #32524] history command overwrites files
From: |
Thorsten Meyer |
Subject: |
[Octave-bug-tracker] [bug #32524] history command overwrites files |
Date: |
Thu, 17 Feb 2011 21:27:43 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20110109 Iceweasel/3.6.13 (like Firefox/3.6.13) |
URL:
<http://savannah.gnu.org/bugs/?32524>
Summary: history command overwrites files
Project: GNU Octave
Submitted by: tmeyier
Submitted on: Thu 17 Feb 2011 09:27:42 PM UTC
Category: Interpreter
Severity: 4 - Important
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux
_______________________________________________________
Details:
I have been using the command
history -w new_script.m
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
history -w new_script.m
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
history_file
still gives
ans = /home/thorsten/.octave_hist
Interestingly, when I explicitly set the history filename with
history_file some_other_filename
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:
history_file -r myfile.m
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
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Thu 17 Feb 2011 09:27:42 PM UTC Name: fix_history_bug Size: 1kB By:
tmeyier
<http://savannah.gnu.org/bugs/download.php?file_id=22719>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?32524>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #32524] history command overwrites files,
Thorsten Meyer <=