[clang-repl] support XDG directory structure for .clang-repl-history
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
On Linux, `clang-repl`'s history is currently stored in the user's `$HOME` directory as `.clang-repl-history`. [Here](https://github.com/llvm/llvm-project/blob/2adf5add2f7764bfdcaa29614acc0d12c00f70bd/llvm/lib/LineEditor/LineEditor.cpp#L25) is the relevant code.
I would ask if LLVM could support the [XDG directory structure](https://wiki.archlinux.org/title/XDG_Base_Directory) and store this file in the `$XDG_STATE_HOME` directory. For example, if this environment variable is not modified by the user, the default path to the history should be `~/.local/state/clang-repl-history`.
Additionally, I suggest that, if a `.clang-repl-history` file is present in the user's `$HOME` directory, no new history file is created, and the user's previous history is reused.
Related issue: #71426
Contributor guide
Research direction
Start in llvm/lib/LineEditor/LineEditor.cpp at the history-path logic linked in the issue, then review the XDG Base Directory guidance for Linux state files. Done means clang-repl uses the requested XDG state location by default and reuses an existing $HOME/.clang-repl-history instead of creating a new history file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100