fix: write the prompt to STDOUT before readline() on Windows - #10534
Open
michalsn wants to merge 1 commit into
Open
fix: write the prompt to STDOUT before readline() on Windows#10534michalsn wants to merge 1 commit into
michalsn wants to merge 1 commit into
Conversation
paulbalandan
approved these changes
Sep 8, 2026
samsonasik
approved these changes
Sep 8, 2026
datamweb
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is a follow-up to #10507. On Windows
readline_info()never exposes alibrary_versionkey: php-src adds it under#ifndef PHP_WIN32(ext/readline/readline.c), because the extension is built on WinEditLine there instead of GNU readline.readline_info('library_version')therefore returnsnullon every Windows build with the extension enabled, and underdeclare(strict_types=1)the newstr_contains()call inInputOutput::input()throws:Every spark command that asks a question (e.g.
shield:setup, or any generator asked to overwrite a file) crashes on Windows since #10507, whenever thereadlineextension is enabled (the default in the official builds). Windows withreadlinedisabled is not affected, asinput()takes thefgets()path. Reproduced with the official PHP 8.4.25 and 8.0.25 builds.A plain null guard is not enough: WinEditLine prints ANSI sequences passed in the readline prompt literally, so a coloured default option would render as
[[32my[0m, n]:. This PR extracts the prompt decision intoInputOutput::readlinePrompt():8.2) gets the prompt with ANSI sequences wrapped in the non-printing markers, as in fix: pass prompt text to readline inCLI::prompt()so backspace does not erase it #10507.EditLine wrapper) gets the raw prompt, as in fix: pass prompt text to readline inCLI::prompt()so backspace does not erase it #10507.readline()only reads the line, i.e. the pre-fix: pass prompt text to readline inCLI::prompt()so backspace does not erase it #10507 behaviour.Tested interactively on Windows 11 / PHP 8.4.25 with
CLI::prompt(),CLI::promptByKey()and a plain prompt: colours render correctly, the typed values come back, and the prompt text stays intact after backspacing past the start of the input (WinEditLine is not affected by the bug #10507 fixed, so the old behaviour is safe there).Checklist: