When prompting the user for a password, we need to temporarily disable
echo. In a tty we can call posix stty -echo (example below). The
RStudio GUI has a native password entry function that can be triggered
via getOption('askpass'). Is there simple method to prompt for a
password in the R for Mac GUI (without depending on shiny or tcltk)?

readline_password <- function(prompt = "Please enter password\n"){
  if(isatty(stdin())){
    if(system('stty -echo') == 0){
      on.exit(system('stty echo'))
    }
  }
  base::readline(prompt)
}

_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to