git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2][Perlers?] git-send-email: ssh/login style password requests

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 2, 2008, 21:31 UTC
Message-ID
<7vve5711wa.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1201925161-9864-1-git-send-email-mfwitten@mit.edu>
Michael Witten <mfwitten@MIT.EDU> writes:
>  2 files changed, 53 insertions(+), 9 deletions(-)
Documentation part looks very clear.  Thanks.
Show 15 quoted lines
> +		if (defined $smtp_authuser) {
> +
> +			if (!defined $smtp_authpass) {
> +				
> +				system "stty -echo";
> +
> +				do {
> +					$_ = $term->readline("Password: ");
> +				} while (!defined $_);
> +
> +				system "stty echo";
> +
> +				$smtp_authpass = $_ if ($_);
> +			}
> +

Another example which appears in PerlFAQ #8 uses ReadKey with its ReadLine, like this:

    use Term::ReadKey;
    ReadMode('noecho');
    $password = ReadLine(0);

which is different from Term::ReadLine's "ReadLine". An earlier example you cited from perlfunc.pod's crypt() entry does:

    system "stty -echo";
    print "Password: ";
    chomp($word = <STDIN>);
    print "\n";
    system "stty echo";

In either case, I was worried about the interaction between the Term::ReadLine backend implementation and "stty".

Actually, I just tried this myself:
    #!/usr/bin/perl -w
    use Term::ReadLine;
    my $term = new Term::ReadLine 'foobar';
    my ($user, $password);
    while (!defined $user) {
            $user = $term->readline("User: ");
    }
    system 'stty -echo';
    while (!defined $password) {
            $password = $term->readline("Password: ");
    }
    system 'stty echo';
    print "You said <$user><$password>\n";
    print "ReadLine backend used was ", $term->ReadLine, "\n";

In my case, the backend was "Term::ReadLine::Perl". A few problems:

 * After typing "junio <Enter>" to "User:", an extra newline is
   left before "Password:" prompt;
 * "Password:" prompt still echoed password "abc".  There was no
   extra newline before "You said <junio><abc>".
 * In either case, typing <Enter> returns an empty string from
   $term->readline() so the "while (!defined)" loop does not buy
   us anything.
 
Previous: Junio C HamanoNext: Michael Witten
Message 11 of 16 in “git-send-email: ssh/login style password requests”
  1. git-send-email: ssh/login style password requestsMichael Witten, Feb 1, 2008
  2. Junio C HamanoFeb 1, 2008
  3. Michael WittenFeb 1, 2008
  4. Michael WittenFeb 1, 2008
  5. Junio C HamanoFeb 1, 2008
  6. Michael WittenFeb 1, 2008
  7. Junio C HamanoFeb 2, 2008
  8. 1/2 [Perlers?] git-send-email: ssh/login style password requestsMichael Witten, Feb 2, 2008
  9. 2/2 [Perlers?] git-send-email: SIG{TERM,INT} handlersMichael Witten, Feb 2, 2008
  10. Junio C HamanoFeb 2, 2008
  11. Junio C HamanoFeb 2, 2008
  12. Michael WittenFeb 3, 2008
  13. Michael WittenFeb 3, 2008
  14. 1/3 [V.2] git-send-email: ssh/login style password requestsMichael Witten, Feb 4, 2008
  15. 2/3 [V.2] git-send-email: SIG{TERM,INT} handlersMichael Witten, Feb 4, 2008
  16. 3/3 [V.2] git-send-email: Better handling of EOF [^D]Michael Witten, Feb 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.