Mercurial > octave
diff libinterp/corefcn/oct-hist.cc @ 28854:491433ba8612
Move history file location to inside XDG_CONFIG_HOME or APPDATA (bug #57463).
* oct-env.cc, oct-envh (get_user_data_directory, do_get_user_data_directory):
New functions.
* oct-hist.cc (history_system::default_file): Store history at platform
dependent location by default.
(Fhistory_file): Document new default location for history file.
* cmd-hist.cc (gnu_history::do_write): Create directory if it doesn't exist.
* NEWS: Announce changed history file location.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 12 May 2020 16:57:31 +0200 |
parents | 445e5ac1f58d |
children | 43ad651cf5a0 |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-hist.cc Thu Oct 01 23:26:28 2020 +0200 +++ b/libinterp/corefcn/oct-hist.cc Tue May 12 16:57:31 2020 +0200 @@ -547,8 +547,18 @@ file = env_file; if (file.empty ()) - file = sys::file_ops::concat (sys::env::get_home_directory (), - ".octave_hist"); + { + // Default to $DATA/octave/history, where $DATA is the platform- + // dependent location for (roaming) user data files. + + std::string user_data_dir = sys::env::get_user_data_directory (); + + std::string hist_dir = user_data_dir + sys::file_ops::dir_sep_str () + + "octave"; + + file = sys::env::make_absolute ("history", hist_dir); + } + return file; } @@ -821,8 +831,11 @@ All future commands issued during the current Octave session will be written to this new file (if the current setting of @code{history_save} allows for this). -The default value is @file{~/.octave_hist}, but may be overridden by the -environment variable @w{@env{OCTAVE_HISTFILE}}. +The default value is @file{@w{@env{$DATA}}/octave/history}, where +@w{@env{$DATA}} is the platform-specific location for (roaming) user data files +(e.g. @w{@env{$XDG_DATA_HOME}} or, if that is not set, @file{~/.local/share} on +Unix-like operating systems or @w{@env{%APPDATA%}} on Windows). The default +value may be overridden by the environment variable @w{@env{OCTAVE_HISTFILE}}. Programming Notes: