Skip to content

Commit ffbb4b7

Browse files
committed
fix: CLI::prompt() may incorrectly return default value
See CLITest::testPromptInputZero().
1 parent aa1d6c6 commit ffbb4b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

system/CLI/CLI.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ public static function prompt(string $field, $options = null, $validation = null
258258
static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': ');
259259

260260
// Read the input from keyboard.
261-
$input = trim(static::$io->input()) ?: (string) $default;
261+
$input = trim(static::$io->input());
262+
$input = ($input === '') ? (string) $default : $input;
262263

263264
if ($validation !== []) {
264265
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {

0 commit comments

Comments
 (0)