From 25b669c144949816d3c9726c79dbd6e93d53ee8b Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 2 Oct 2000 23:19:38 +0000 Subject: [PATCH] Try to guess an output filename --- networking/wget.c | 12 ++++++++++-- wget.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/networking/wget.c b/networking/wget.c index 58801ee47..c95271b0d 100644 --- a/networking/wget.c +++ b/networking/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. */ diff --git a/wget.c b/wget.c index 58801ee47..c95271b0d 100644 --- 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. */ -- 2.25.1