I have a test program that produces a lengthy output, so I ran it in "Shell". However, at some point the test program prompts for a password, and when entering it, the characters are displayed, even if the program has set "echo off" (it's a Perl program that uses ReadMode('noecho');).
Is there a way to prevent keyboard echo during password input?
Code sample
As the solution seems to depend on the actual code being used, here is a routine to "get a PIN":
# read PIN from STDIN use Term::ReadKey; sub read_PIN(;$) { my $PIN; if (-t STDIN) { my $prompt = 'PIN:'; $prompt = $_[0] . ' ' . $prompt if ($_[0]); ReadMode('noecho'); # disable echo print $prompt if (-t STDOUT); # use a prompt $PIN = <STDIN>; print "\n" if (-t STDOUT); ReadMode('normal'); # re-enable echo } else { $PIN = <STDIN>; } chomp($PIN); return $PIN; } # use example: $PIN = read_PIN('some detail');
comint-password-prompt-regexp?comint-password-prompt-regexplacksPIN:and 2) (even more worse) my program suppresses the promptunless (-t STDIN)(which seems true for Emacs' shell mode).ansi-term, but it's probably easier to change your code to always prompt with something like "Password:"ansi-term; when I tried it, it worked!ansi-termseems to have a limited or no scroll-back buffer, so I see no advantage compared to using the terminal directly.