Try to guess an output filename
authorEric Andersen <andersen@codepoet.org>
Mon, 2 Oct 2000 23:19:38 +0000 (23:19 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 2 Oct 2000 23:19:38 +0000 (23:19 -0000)
networking/wget.c
wget.c

index 58801ee47885115e4aeeab24859ebe9312c9584d..c95271b0da1460db0b7e45bc825c348bb62f46b6 100644 (file)
@@ -56,10 +56,18 @@ int wget_main(int argc, char **argv)
                        usage(wget_usage);
                }
        }
-       if (do_continue && !fname_out)
-               fatalError("wget: cannot specify continue (-c) without a filename (-O)\n");
+
        if (argc - optind != 1)
                        usage(wget_usage);
+
+       /* Guess an output filename */
+       if (!fname_out) {
+               fname_out = get_last_path_component(argv[optind]);
+       }
+
+       if (do_continue && !fname_out)
+               fatalError("wget: cannot specify continue (-c) without a filename (-O)\n");
+
        /*
         * Parse url into components.
         */
diff --git a/wget.c b/wget.c
index 58801ee47885115e4aeeab24859ebe9312c9584d..c95271b0da1460db0b7e45bc825c348bb62f46b6 100644 (file)
--- a/wget.c
+++ b/wget.c
@@ -56,10 +56,18 @@ int wget_main(int argc, char **argv)
                        usage(wget_usage);
                }
        }
-       if (do_continue && !fname_out)
-               fatalError("wget: cannot specify continue (-c) without a filename (-O)\n");
+
        if (argc - optind != 1)
                        usage(wget_usage);
+
+       /* Guess an output filename */
+       if (!fname_out) {
+               fname_out = get_last_path_component(argv[optind]);
+       }
+
+       if (do_continue && !fname_out)
+               fatalError("wget: cannot specify continue (-c) without a filename (-O)\n");
+
        /*
         * Parse url into components.
         */