Re: [Bug-wget] Use stderr instead of stdout for --ask-password

2011-02-24 Thread Giuseppe Scrivano
Micah Cowan mi...@cowan.name writes:

 Changing the prompt to stderr seems like a simple, single step forward
 towards proper usage. It's not perfect, but it strikes me as a good
 sight better than using stdout, which really ought to be reserved for
 program results-type output, IMO.

I have applied the original patch, which prompt to stderr instead of
stdout.  I agree it is not the ideal usage, but the current decision is
about use stderr or inhibit the message at all; considering the
diagnostic nature of stderr, then the former seems a better choice.

Thanks,
Giuseppe



Re: [Bug-wget] Use stderr instead of stdout for --ask-password

2011-02-23 Thread Giuseppe Scrivano
Hello Gilles,

thanks for your patch.  I am not sure it is a good idea to use stderr
to prompt a message to the user.  I would just inhibit the message when
-O- is used.

Cheers,
Giuseppe



Gilles Carry gilles.ca...@st.com writes:

 Hello,

 Here is a small patch to change the ask-password behaviour.
 You may find the explanation in patch's changelog.
 I confess I did not test much this patch.

 Best regards,
 Thank-you,
 Gilles.

 diff --git a/src/ChangeLog b/src/ChangeLog
 index f37814d..b9bf2d7 100644
 --- a/src/ChangeLog
 +++ b/src/ChangeLog
 @@ -1,3 +1,13 @@
 +2011-02-22  Gilles Carry  gilles dot carry at st dot com
 +
 + * main.c (prompt_for_password): Use stderr instead of stdout
 + to prompt password. This allows to use --output-document=- and
 + --ask-password simultaneously. Without this, redirecting stdout
 + makes password prompt invisible and mucks up payload such as in
 + this example:
 + wget --output-document=- --ask-password -user=foo \
 + http://foo.com/tarball.tgz | tar zxf -
 +
  2009-09-22  Micah Cowan  mi...@cowan.name
  
   * openssl.c (ssl_check_certificate): Avoid reusing the same buffer
 diff --git a/src/main.c b/src/main.c
 index dddc4b2..db1638f 100644
 --- a/src/main.c
 +++ b/src/main.c
 @@ -725,9 +725,9 @@ static char *
  prompt_for_password (void)
  {
if (opt.user)
 -printf (_(Password for user %s: ), quote (opt.user));
 +fprintf (stderr, _(Password for user %s: ), quote (opt.user));
else
 -printf (_(Password: ));
 +fprintf (stderr, _(Password: ));
return getpass();
  }
  



Re: [Bug-wget] Use stderr instead of stdout for --ask-password

2011-02-23 Thread Giuseppe Scrivano
Micah Cowan mi...@cowan.name writes:

 On 02/23/2011 01:23 AM, Giuseppe Scrivano wrote:
 Hello Gilles,
 
 thanks for your patch.  I am not sure it is a good idea to use stderr
 to prompt a message to the user.  I would just inhibit the message when
 -O- is used.

 Personally, I agree with Gilles; in every single instance other than
 here, we always write information meant for the user to stderr (I
 believe for the reason he cites: so as not to interfere with the output
 in the case of -O-). I'd say we should either blindly write to stderr in
 all cases, or else consider specifically finding the terminal and
 writing to that (ttyname?)

hm.. in functions like print_usage (main.c), I see we differentiate
between an error message and an usage string.  When the user specifies
--ask-password then the password prompt is a desired behaviour rather
than an error.

In what cases do we use stderr for something different than an error
message?

Giuseppe