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

cli: allow to change ~/.php_history with PHP_HISTFILE #13964

Closed
wants to merge 1 commit into from

Conversation

spk
Copy link
Contributor

@spk spk commented Apr 15, 2024

why

Allow to change .php_history repl file with PHP_HISTFILE environment variable

how

If the env var is present use it first then fallback to HOME or USERPROFILE on windows

(i'm not a C developer any help/feedback welcome thanks)

@ranvis
Copy link
Contributor

ranvis commented Apr 15, 2024

Related: #8546

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @spk! Looks reasonable in general.

ext/readline/readline_cli.c Show resolved Hide resolved
sapi/cli/tests/017.phpt Show resolved Hide resolved
$dir = PHP_OS_FAMILY == 'Windows' ? getenv("USERPROFILE") : getenv("HOME");
var_dump(file_exists($dir . '/.php_history'));

define("TMPDIR", __DIR__ . "/");
$php_history_tmp = TMPDIR . "php_history";
Copy link
Member

@iluuu1994 iluuu1994 Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use $php_history_tmp = tempnam(sys_get_temp_dir(), 'php_history'); to avoid having to clean up the file and putting it in the ignore list.

Edit: Or just sys_get_temp_dir() . '/php_history', as tempnam will create an empty file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks i've applied the changes, current CI failure doesn't look related

@spk spk force-pushed the php-histfile-env branch 2 times, most recently from ee1a2e0 to 609429d Compare April 19, 2024 09:18
@iluuu1994
Copy link
Member

Merged as 3f0b204. (Linked the wrong PR...)

@iluuu1994 iluuu1994 closed this Apr 22, 2024
@iluuu1994
Copy link
Member

Thank you @spk!

@spk spk deleted the php-histfile-env branch April 22, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants