Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link-parser's history file location control #1534

Merged
merged 7 commits into from
May 25, 2024
Merged

Conversation

ampli
Copy link
Member

@ampli ampli commented May 24, 2024

In this PR:
The location of the history file is according to, in this order.
XDG_STATE_HOME
HOME

The history file name is X_history when X is the dict name to support a different history file per dict. For example, en_history. To support using the same history file for more than one dict, X is the dict name until the first :. For example, the dicts en and en:test use the save history file en_history.

I tested it on MinGW (no editline, just that it doesn't break compilation), Cygwin, macOS, and Linux.
It cannot be tested on MSVC because the MSVC build recently became broken in more than one way (PR soon). (The only test needed for now is that the changes of this PR don't break the build, as there is no editline support for Windows.)

This PR includes a minimal XDG support module I wrote instead of using a system library. One reason is that the current libraries don't support XDG_STATE_HOME, which was added to the standard relatively recently.

Comments:

  • If XDG_STATE_HOMOCE is invalid (not absolute or not writeable), it is ignored. However, if HOME is invalid (undefined, not absolute, or not writeable), there is no fallback, and the history is disabled.
  • Currently, verbosity=4, intended to show the location of files, doesn't show the location of the history file because the verbosity variable is currently not in the needed scope.

EDIT: I tried to configure with HAVE_ASPRINTF=0 and got a segfault. So, I forced-push a fix. (This also demonstrates that using #if HAVE_FEATURE is better than #ifdef HAVE_FEATURE because it allows such easy tests.)

Ref. PR #1446.

@linas linas merged commit d1b9d40 into opencog:master May 25, 2024
1 check passed
@linas
Copy link
Member

linas commented May 25, 2024

wow!

@linas
Copy link
Member

linas commented Jun 3, 2024

For the record; on my machine, this ends up in /home/linas/.local/state/link-parser/en_history Curiously, ~/.local/state/ has only one other dir in it: wireplumber which I think is sound-system related. All other apps on my system write to /home/linas/.cache

@linas
Copy link
Member

linas commented Jun 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants