bugGNU Octave - Bugs: bug #57027, Unclear documentation for command...

 
 

bug #57027: Unclear documentation for command "history_file"

Submitted by:  Hartmut <hardy>
Submitted on:  Wed 09 Oct 2019 08:10:57 PM UTC  
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  5.1.0 Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Wed 23 Oct 2019 03:21:20 PM UTC, comment #4: 

I made a few tweaks to the language and checked the change in under your name on the stable branche of Octave.  See https://hg.savannah.gnu.org/hgweb/octave/rev/8c9924a425db.

This will be a part of the next bug fix release of Octave.

Marking as fixed and closing report.

Rik <rik5>
Project Administrator
Sat 12 Oct 2019 05:30:36 PM UTC, comment #3: 

Sorry, the code snippet I proposed for the help text in comment #2 does not work. Please use the following code snippet instead:

   history_file ("~/new/.octave_hist");
   if (exist (history_file ()))
     history('-r', history_file());
   endif

Hartmut <hardy>
Sat 12 Oct 2019 08:38:17 AM UTC, comment #2: 

Thanks for the additional hints. And sorry, I don't intend to open a seperate bug report for all of my "support" questions, in general.

Yes, I think adding some explanations to the help string of the history_file command would be useful.

Here is my suggestion for this:

VAL = history_file ()

OLD_VAL = history_file (NEW_VAL)

Query or set the internal variable that specifies the name of the
file used to store command history.

All future Octave commands issued during the current Octave session
will then be written into this new file (if the current setting of
"history_save" allows for this).

The default value for the history file is '~/.octave_hist', but this
may be overridden by the environment variable 'OCTAVE_HISTFILE'.

Notes:

* If you want to permanently change the location of Octave's history
file you need to reissue the "history_file" command in every new Octave session.
This can be achived by using Octave's ".octaverc" startup file.

* If you also want to read the saved history commands of past Octave sessions
from this different history file, then you need to use the additional command
"history -r" after setting the new value of the history file. A useful code
in Octave's startup file to do this could look like this:

   history_file ("~/new/.octave_hist");
   if (exist (history_file ())
     history -r
   endif


See also: history, history_size, history_save,
history_control, history_timestamp_format_string.

Hartmut <hardy>
Wed 09 Oct 2019 09:07:20 PM UTC, comment #1: 

Setting the history file applies to all future history commands, it does not immediately re-read the history from the new file. This is analogous to the bash command history file. If you want to both change the name of the file used for saving and for restoring history, you should use

history_file ("~/test/.octave_hist");
if (exist (history_file ())
  history -r
  ## or equivalently, history ("-r", history_file ());
endif

I successfully use a combination of history_control(), history_file(), history_save(), history_size(), and history("-r") in my ~/.octaverc, in that order.

Can you suggest any changes to the relevant doc strings that would help make it clear that setting history_file to a new file does not automatically trigger a read of the file?

(And sorry for omitting to mention this in the other bug report.)

Mike Miller <mtmiller>
Project Administrator
Wed 09 Oct 2019 08:10:57 PM UTC, original submission:  

I tried to use the Octave command "history_file()" for what I think it's ment for, but it doesn't work properly.

Here is a way to reproduce it:

  • change your .octaverc or startup.m file such that it contains the following line of code: "history_file('~/test/.octave_hist');"
  • delete the already existing history file ".octave_hist" in your home folder (and maybe all other existing .octave_hist file in your system).
  • start Octave
  • type some commands into Octave, e.g. "123+456" and execute them
  • close Octave again
  • look into the folder "test", it will now have the history file ".octave_hist" that properly contains your freshly typed commands. So far, so good.
  • now restart Octave
  • look at the history (it will be empty), or type the "arrow up" key in the command window (nothing will show up)

I have observed this behavior with Octave 5.1 release, under Win10 as well as under (Ubuntu) linux. Since I assume that this command "history_file()" used to work properly at some time ago (the descsribed use case is the only one this Octave command seems to have) I classified this bug report as "regression".

(Maybe there is only the "append" option missing in this case of a non-standard file location of the Octave history file?)

Hartmut <hardy>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by hardy (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-10-23 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2019-10-10 rik5 CategoryOctave Function => Documentation
        Item GroupRegression => Documentation
        StatusNone => Confirmed
        Summarycommand "history_file" does not work properly => Unclear documentation for command "history_file"

    Back to the top


    Powered by Savane 3.5