[php-src] Issue #8546: Feature request: XDG Base Directory for .php_history

From: Date: Fri, 13 May 2022 10:09:23 +0000
Subject: [php-src] Issue #8546: Feature request: XDG Base Directory for .php_history
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241474@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8546 Author: nsfisis ### Description [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) is a specification that defines a list of directories where applications should store configs/data/caches. It is not required to follow, but [many applications](https://wiki.archlinux.org/title/XDG_Base_Directory#Support) support it today. For PHP, the location of .php_history, a file storing command line history in the REPL (php -a), is fixed to home directory. ext/readline/readline_cli.c: ```c #ifndef PHP_WIN32 history_file = tilde_expand("~/.php_history"); #else spprintf(&history_file, MAX_PATH, "%s/.php_history", getenv("USERPROFILE")); #endif ``` There are several ways to support XDG Base Directory: * Change path of .php_history to $XDG_DATA_HOME/php/history. If $XDG_DATA_HOME is not defined, use $HOME/.local/share instead. * Change default path of .php_history to $XDG_DATA_HOME/php/history only if $XDG_DATA_HOME is defined. If not, use $HOME/.php_history as before. * Introduce a new environment variable to set history file path like $PHP_HISTFILE. If $PHP_HISTFILE is not set, use $HOME/.php_history as before.

« previous php.bugs (#241474) next »