Closing stdin causes prompt()
to output a newline, in contrast to confirm()
#22956
Labels
bug
Something isn't working correctly
good first issue
Good for newcomers
runtime
Relates to code in the runtime crate
Running the following command and pressing Ctrl+D to close the standard input stream reveals that the built-in
prompt()
function outputs a newline in this case:Surprisingly,
confirm()
does not exhibit this behavior (note the location of the second$
prompt):I would argue that the latter response is more correct, by analogy with C. Consider the following POSIX.1-2008–compliant program:
Hitting Ctrl+D elicits the
confirm()
-style behavior on my GNU/Linux system:I noticed this inconsistency when filing #22955: it is responsible for the extra newline in the final command-line example in that issue. I haven't traced the issue deeper than
prompt()
's use ofop_read_line_prompt()
(in contrast toconfirm()
'sreadLineFromStdinSync()
) inruntime/js/41_prompt.js
.Tested on this official release build:
The text was updated successfully, but these errors were encountered: