[R] readline in function call with space in prompt.

Jeremie Juste jerem|eju@te @end|ng |rom gm@||@com
Mon Feb 8 14:28:33 CET 2021


I have noticed a behavior that I don't understand. When I call the
following function from the prompt.
test <- function(){
    a <- readline("selection: ")

> test()
> selection: |
I can only type one character and the readline function exits before I can
press enter.


test1 <- function(){
    a <- readline("selection:")
> test1()
> selection:|
works as expected.
> selection: abc[Ret]

However calling directly readline with a space in the prompt does what I
would expect.

> a <- readline("selection: ")
> selection: abc[Ret]
> a
> "abc"

It is the expected behavior or am I missing something?

Best regards,
Jeremie Juste
> R version 4.0.3 (2020-10-10)

More information about the R-help mailing list