#include "http.h" /* for save_cookies */
#include <getopt.h>
-#include "getpass.h"
+#include <getpass.h>
+#include <quote.h>
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
init_switches (void)
{
char *p = short_options;
- int i, o = 0;
+ size_t i, o = 0;
for (i = 0; i < countof (option_data); i++)
{
struct cmdline_option *opt = &option_data[i];
N_("Mail bug reports and suggestions to <bug-wget@gnu.org>.\n")
};
- int i;
+ size_t i;
printf (_("GNU Wget %s, a non-interactive network retriever.\n"),
version_string);
prompt_for_password (void)
{
if (opt.user)
- printf (_("Password for user \"%s\": "), opt.user);
+ printf (_("Password for user %s: "), quote (opt.user));
else
printf (_("Password: "));
return getpass("");
}
if (opt.timestamping)
{
- fputs (_("\
-Cannot specify -N if -O is given. See the manual for details.\n\n"), stdout);
- print_usage ();
- exit (1);
+ logprintf (LOG_NOTQUIET, "%s", _("\
+WARNING: timestamping does nothing in combination with -O. See the manual\n\
+for details.\n\n"));
+ opt.timestamping = false;
}
+ if (opt.noclobber && file_exists_p(opt.output_document))
+ {
+ /* Check if output file exists; if it does, exit. */
+ logprintf (LOG_VERBOSE, _("File `%s' already there; not retrieving.\n"), opt.output_document);
+ exit(1);
+ }
}
if (opt.ask_passwd && opt.passwd)
exit (1);
}
+ if (opt.ask_passwd)
+ {
+ opt.passwd = prompt_for_password ();
+
+ if (opt.passwd == NULL || opt.passwd[0] == '\0')
+ exit (1);
+ }
+
#ifdef MSDOS
if (opt.wdebug)
dbug_init();
if (opt.output_document)
{
if (HYPHENP (opt.output_document))
- output_stream = stdout;
+ {
+#ifdef WINDOWS
+ FILE *result;
+ result = freopen (NULL, "wb", stdout);
+ if (result == NULL)
+ {
+ logputs (LOG_NOTQUIET, _("\
+WARNING: Can't reopen standard output in binary mode;\n\
+ downloaded file may contain inappropriate line endings.\n"));
+ }
+#endif
+ output_stream = stdout;
+ }
else
{
struct_fstat st;
char *filename = NULL, *redirected_URL = NULL;
int dt;
- if (opt.ask_passwd)
- opt.passwd = prompt_for_password ();
-
if ((opt.recursive || opt.page_requisites)
&& (url_scheme (*t) != SCHEME_FTP || url_uses_proxy (*t)))
{