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:
$ deno eval 'prompt()'
Prompt
$
Surprisingly, confirm() does not exhibit this behavior (note the location of the second $ prompt):
$ deno eval 'confirm()'
Confirm [y/N] $
I would argue that the latter response is more correct, by analogy with C. Consider the following POSIX.1-2008–compliant program:
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
int main(void) {
fputs("Prompt ", stdout);
char *buf = NULL;
size_t len = 0;
getline(&buf, &len, stdin);
free(buf);
return 0;
}
Hitting Ctrl+D elicits the confirm()-style behavior on my GNU/Linux system:
$ c99 -o getline getline.c && ./getline
Prompt $
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 of op_read_line_prompt() (in contrast to confirm()'s readLineFromStdinSync()) in runtime/js/41_prompt.js.
Tested on this official release build:
$ deno --version
deno 1.41.0 (release, x86_64-unknown-linux-gnu)
v8 12.1.285.27
typescript 5.3.3