]> sjero.net Git - wget/blobdiff - src/main.c
Fixed bug #23238: --no-clobber doesn't work with -O flag
[wget] / src / main.c
index b1e99695f19f124bc45af691a145be5b9324bc98..fdf368a51fc2e897e9fc2e236a8d5e9744bea2f5 100644 (file)
@@ -880,22 +880,37 @@ Can't timestamp and not clobber old files at the same time.\n"));
       exit (1);
     }
 #endif
-  if (opt.output_document
-      && (opt.page_requisites
-          || opt.recursive
-          || opt.timestamping))
-    {
-          printf (_("Cannot specify -r, -p or -N if -O is given.\n"));
-          print_usage ();
-          exit (1);
-    }
-  if (opt.output_document
-      && opt.convert_links 
-      && nurl > 1)
+  if (opt.output_document)
     {
-          printf (_("Cannot specify both -k and -O if multiple URLs are given.\n"));
+      if (opt.convert_links 
+          && (nurl > 1 || opt.page_requisites || opt.recursive))
+        {
+          fputs (_("\
+Cannot specify both -k and -O if multiple URLs are given, or in combination\n\
+with -p or -r. See the manual for details.\n\n"), stdout);
           print_usage ();
           exit (1);
+        }
+      if (opt.page_requisites
+          || opt.recursive)
+        {
+          logprintf (LOG_NOTQUIET, "%s", _("\
+WARNING: combining -O with -r or -p will mean that all downloaded content\n\
+will be placed in the single file you specified.\n\n"));
+        }
+      if (opt.timestamping)
+        {
+          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 (!nurl && !opt.input_filename)